/* ============================================
   IP-CHAT — Design System v2
   "A ghost in the machine." — Dark, cosmic, cinematic
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Syne:wght@500;600;700;800&family=Playfair+Display:ital,wght@0,700;1,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Design Tokens --- */
:root {
  /* Background */
  --bg: #050508;
  --bg-surface: #0c0c12;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.05);

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(255, 255, 255, 0.25);

  /* Text */
  --text-primary: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.25);
  --text-error: #ff6b6b;

  /* Accent — pure white */
  --accent: #ffffff;
  --glow: rgba(255, 255, 255, 0.06);

  /* Layout */
  --sidebar-width: 72px;
  --radius-full: 999px;
  --radius-bubble: 20px;
  --radius-lg: 20px;
  --radius-md: 14px;

  /* Typography */
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-logo: 'Syne', 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 200ms;
  --t-normal: 250ms;
  --t-slow: 300ms;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 0.01em;
}

/* --- Film Grain Overlay --- */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
}

/* --- Particle Canvas --- */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.45;
}

/* --- Screen System --- */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease),
              transform var(--t-slow) var(--ease);
  transform: translateY(10px) scale(0.99);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ============================================
   HOME SCREEN
   ============================================ */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
}

/* — Logo — */
.logo-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  animation: logoPulse 4s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.03); }
  50% { box-shadow: 0 0 24px 4px rgba(255, 255, 255, 0.04); }
}

.logo-text {
  font-family: var(--font-logo);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.logo-tagline {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
  font-family: var(--font-body);
}

/* — Join Card (Glass) — */
.join-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(32px) saturate(160%);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--t-slow) var(--ease);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 48px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.join-card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

.card-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
}

.card-dot:nth-child(1) { background: rgba(255, 255, 255, 0.2); }
.card-dot:nth-child(2) { background: rgba(255, 255, 255, 0.15); }
.card-dot:nth-child(3) { background: rgba(255, 255, 255, 0.1); }

.card-title {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
  font-family: var(--font-body);
}

.card-body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* — Input Groups — */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: var(--font-body);
}

.optional {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  font-size: 0.7rem;
  letter-spacing: 0;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  transition: all var(--t-fast) ease;
}

.input-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.input-prefix {
  font-size: 1rem;
  color: var(--text-muted);
  padding-left: 18px;
  user-select: none;
  font-weight: 500;
}

.input-wrapper input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Room ID inputs use monospace */
#room-id-input {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input-status {
  width: 20px;
  height: 20px;
  margin-right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: opacity var(--t-fast) var(--ease);
  opacity: 0;
}

.input-status.valid {
  opacity: 1;
  color: rgba(255, 255, 255, 0.5);
}

.input-status.valid::after {
  content: '✓';
}

.input-status.invalid {
  opacity: 1;
  color: var(--text-error);
}

.input-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-left: 18px;
  font-family: var(--font-body);
}

/* — Join Button (Primary / White Filled) — */
.join-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-full);
  background: #ffffff;
  color: #000000;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) ease;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.08);
}

.join-btn:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 0 32px rgba(255, 255, 255, 0.18);
}

.join-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.join-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

.btn-icon {
  transition: transform var(--t-normal) var(--ease);
}

.join-btn:hover:not(:disabled) .btn-icon {
  transform: translateX(3px);
}

/* — Error — */
.error-msg {
  font-size: 0.78rem;
  color: var(--text-error);
  text-align: center;
  min-height: 20px;
  transition: opacity var(--t-normal);
  font-family: var(--font-body);
}

/* — Features Row — */
.features {
  display: flex;
  gap: 24px;
}

.feature {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-body);
}

.feature-icon {
  font-size: 0.95rem;
}

.visible-credit {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.75);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
  font-family: var(--font-body);
}

.home-credit {
  margin-top: -10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border-color: var(--border);
}

/* ============================================
   CHAT SCREEN
   ============================================ */
#chat-screen.active {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

/* — Sidebar (Glass) — */
.sidebar {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
  z-index: 5;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Sidebar Buttons */
.sidebar-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all var(--t-fast) ease;
  position: relative;
}

.sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.16);
  transform: scale(1.08);
}

.sidebar-btn:active {
  transform: scale(0.95);
}

.sidebar-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: #ffffff;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-body);
  margin-top: auto;
  margin-bottom: 4px;
  cursor: default;
  transition: transform var(--t-normal) var(--ease);
}

.sidebar-avatar:hover {
  transform: scale(1.08);
}

.sidebar-divider {
  width: 28px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* — Main Chat Area — */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg);
}

/* — Chat Header — */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
  flex-shrink: 0;
}

.room-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Pill-shaped room ID */
.room-id-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 18px;
}

.room-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-family: var(--font-body);
}

.room-id-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.user-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.5);
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.count-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-body);
}

/* ============================================
   RECONNECT BANNER
   ============================================ */
.reconnect-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  z-index: 8;
  font-family: var(--font-body);
}

.reconnect-banner.visible {
  display: flex;
}

.reconnect-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* — Messages — */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.messages::-webkit-scrollbar {
  width: 0;
  display: none;
}

.welcome-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-body);
  margin: auto;
  line-height: 1.7;
}

.welcome-icon {
  font-size: 2.2rem;
  filter: grayscale(0.5) brightness(0.8);
}

/* — Message Bubbles (DESIGN.MD spec) — */
.message-bubble {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 18px 18px 18px 4px;
  width: fit-content;
  max-width: 68%;
  align-self: flex-start;
  animation: bubbleIn 300ms var(--spring) both;
  word-wrap: break-word;
  overflow-wrap: break-word;
  transition: background var(--t-fast) var(--ease);
  position: relative;
}

.message-bubble:hover {
  background: rgba(255, 255, 255, 0.07);
}

.message-bubble.self {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.14);
  border-radius: 18px 18px 4px 18px;
  align-self: flex-end;
}

.message-bubble.self:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Spring easing bubble entrance */
@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-nickname {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  font-family: var(--font-body);
}

.message-bubble.self .msg-nickname {
  color: rgba(255, 255, 255, 0.7);
}

.msg-time {
  font-size: 0.64rem;
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-body);
}

.msg-text {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.55;
  font-weight: 400;
  font-family: var(--font-body);
}

/* System Messages */
.system-msg {
  text-align: center;
  font-size: 0.73rem;
  color: var(--text-muted);
  padding: 8px;
  animation: bubbleIn var(--t-slow) var(--ease) both;
  font-family: var(--font-body);
}

.system-msg .sys-highlight {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================
   REACTION BADGE
   ============================================ */
.reaction-badge {
  position: absolute;
  bottom: -6px;
  right: 10px;
  font-size: 0.7rem;
  line-height: 1;
  padding: 2px 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

/* ============================================
   USERS PANEL (slide-in overlay)
   ============================================ */
.users-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 260px;
  max-width: 80%;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(32px) saturate(160%);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  border-left: 1px solid var(--border);
  z-index: 20;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 48px rgba(0, 0, 0, 0.5);
}

.users-panel.open {
  transform: translateX(0);
}

.users-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.users-panel-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: var(--font-body);
}

.users-panel-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--t-fast) var(--ease);
}

.users-panel-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.users-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: none;
}

.users-panel-list::-webkit-scrollbar {
  display: none;
}

.users-panel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  transition: background var(--t-fast) var(--ease);
}

.users-panel-row:hover {
  background: var(--bg-glass-hover);
}

.users-panel-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: var(--font-body);
}

.users-panel-nick {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-body);
}

.users-panel-you {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

/* — Typing Indicator — */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px;
  transition: opacity var(--t-normal), max-height var(--t-normal);
  flex-shrink: 0;
}

.typing-indicator.hidden {
  opacity: 0;
  max-height: 0;
  padding: 0 28px;
  overflow: hidden;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.typing-text {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-body);
}

/* — Message Input (Floating Pill) — */
.message-input-area {
  padding: 14px 24px 24px;
  flex-shrink: 0;
  background: transparent;
}

.chat-credit {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 7px 12px;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border-color: var(--border);
  text-shadow: none;
  font-family: var(--font-body);
}

@media (max-width: 900px) {
  .chat-credit {
    display: none;
  }
}

.message-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  padding: 6px 6px 6px 22px;
  transition: all var(--t-fast) ease;
  position: relative;
}

.message-input-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

#message-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 0;
  resize: none;
  max-height: 120px;
  line-height: 1.45;
  font-weight: 400;
}

#message-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* ============================================
   CHARACTER COUNTER
   ============================================ */
.char-counter {
  display: none;
  position: absolute;
  bottom: 6px;
  right: 58px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 400;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.char-counter.danger {
  color: var(--text-error);
}

/* Send Button (White, Primary) */
.send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  color: #000000;
  cursor: pointer;
  transition: all var(--t-fast) ease;
  flex-shrink: 0;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.08);
}

.send-btn:disabled {
  opacity: 0.12;
  cursor: not-allowed;
  box-shadow: none;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 0 32px rgba(255, 255, 255, 0.18);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(32px) saturate(160%);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  color: var(--text-primary);
  padding: 10px 22px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-body);
  z-index: 100;
  opacity: 0;
  transition: all var(--t-normal) var(--ease);
  pointer-events: none;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   IMAGE PREVIEW AREA (above input bar)
   ============================================ */
.image-preview-area {
  display: none;
  padding: 0 24px 0;
}

.image-preview-area.active {
  display: flex;
}

.image-preview-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px;
  width: fit-content;
  max-width: 100%;
  backdrop-filter: blur(12px);
}

.image-preview-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.image-preview-name {
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  font-family: var(--font-body);
}

.image-preview-cancel {
  width: 26px;
  height: 26px;
  min-width: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--t-fast) var(--ease);
}

.image-preview-cancel:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ============================================
   ATTACH & MIC BUTTONS IN INPUT BAR
   ============================================ */
.attach-btn,
.mic-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast) ease;
  flex-shrink: 0;
}

.attach-btn:hover,
.mic-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.16);
}

/* Mic recording state */
.mic-btn.recording {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--accent);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.15); }
  50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

/* ============================================
   RECORDING INDICATOR (above input bar)
   ============================================ */
.recording-indicator {
  display: none;
  padding: 0 24px 0;
}

.recording-indicator.active {
  display: flex;
}

.recording-indicator-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 16px;
  width: fit-content;
  backdrop-filter: blur(12px);
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: recDotPulse 1s ease-in-out infinite;
}

@keyframes recDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.recording-timer {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

.recording-cancel-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-body);
}

/* ============================================
   IMAGE BUBBLES IN CHAT
   ============================================ */
.msg-image {
  max-width: 280px;
  border-radius: 12px;
  cursor: pointer;
  display: block;
  margin-top: 4px;
  transition: opacity var(--t-fast) var(--ease);
}

.msg-image:hover {
  opacity: 0.85;
}

/* ============================================
   LIGHTBOX OVERLAY
   ============================================ */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 8, 0.95);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.lightbox.active {
  display: flex;
  animation: lbFadeIn var(--t-slow) var(--ease);
}

@keyframes lbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  cursor: default;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  animation: lbImgIn var(--t-slow) var(--ease);
}

@keyframes lbImgIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all var(--t-fast) var(--ease);
  backdrop-filter: blur(12px);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.08);
}

/* ============================================
   VOICE BUBBLE / CUSTOM AUDIO PLAYER
   ============================================ */
.voice-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 260px;
  max-width: 100%;
  margin-top: 4px;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  color: #000;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.08);
}

.voice-play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.15);
}

.voice-play-btn:active {
  transform: scale(0.94);
}

.voice-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.voice-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.voice-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #ffffff;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.voice-duration {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
  .home-container {
    gap: 28px;
    padding: 16px;
  }

  .logo-text {
    font-size: 1.8rem;
  }

  .card-body {
    padding: 20px;
  }

  .features {
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sidebar {
    width: 56px;
  }

  :root {
    --sidebar-width: 56px;
  }

  .sidebar-btn {
    width: 40px;
    height: 40px;
  }

  .sidebar-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }

  .messages {
    padding: 16px 14px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .chat-header {
    padding: 12px 14px;
  }

  .message-input-area {
    padding: 10px 14px 16px;
  }

  .image-preview-area,
  .recording-indicator {
    padding: 0 14px 0;
  }

  .voice-bubble {
    width: 220px;
  }

  .msg-image {
    max-width: 200px;
  }

  .attach-btn,
  .mic-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }
}

@media (max-width: 400px) {
  .sidebar {
    display: none;
  }
}
