/* Responi Design System — Apple-inspired */
/* Single source of truth for all visual tokens */

/* ═══════════ TOKENS ═══════════ */

:root {
  /* Colors — Light */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --bg-chat: #f5f5f7;
  --bg-bubble-in: #ffffff;
  --bg-bubble-out: #007aff;
  --bg-input: #f0f0f5;
  --bg-overlay: rgba(0,0,0,.4);
  --bg-glass: rgba(255,255,255,.72);
  --bg-hover: rgba(0,0,0,.04);
  --bg-active: rgba(0,0,0,.08);

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --text-inverse: #ffffff;
  --text-link: #007aff;
  --text-bubble-out: #ffffff;

  --accent: #007aff;
  --accent-hover: #0066d6;
  --accent-active: #0055b3;
  --green: #30d158;
  --red: #ff3b30;
  --orange: #ff9f0a;
  --purple: #af52de;

  --border: rgba(0,0,0,.08);
  --border-strong: rgba(0,0,0,.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --shadow-glow: 0 0 20px rgba(0,122,255,.15);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', Monaco, Menlo, Consolas, monospace;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 28px;
  --text-3xl: 34px;
  --line-tight: 1.2;
  --line-normal: 1.47;
  --line-relaxed: 1.6;

  /* Spacing (4px grid) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;
  --r-bubble: 18px;

  /* Sizes */
  --avatar-sm: 32px;
  --avatar-md: 40px;
  --avatar-lg: 52px;
  --touch-min: 44px;
  --sidebar-w: 320px;
  --header-h: 52px;
  --input-h: 44px;

  /* Animation */
  --ease: cubic-bezier(.25,.1,.25,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Blur */
  --blur: blur(20px);
  --blur-sm: blur(10px);
}

/* Dark mode */
.dark {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --bg-chat: #000000;
  --bg-bubble-in: #1c1c1e;
  --bg-bubble-out: #007aff;
  --bg-input: #1c1c1e;
  --bg-overlay: rgba(0,0,0,.6);
  --bg-glass: rgba(28,28,30,.72);
  --bg-hover: rgba(255,255,255,.06);
  --bg-active: rgba(255,255,255,.1);

  --text-primary: #f5f5f7;
  --text-secondary: #98989d;
  --text-tertiary: #636366;
  --text-inverse: #000000;

  --border: rgba(255,255,255,.1);
  --border-strong: rgba(255,255,255,.18);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
}

/* ═══════════ BASE ═══════════ */

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--line-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Safe area for iPhone notch + home indicator */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent); color: white; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: var(--r-full); }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ LAYOUT ═══════════ */

.app { height: 100dvh; display: flex; flex-direction: column; }
.layout { flex: 1; display: flex; overflow: hidden; }

/* Header */
.header {
  min-height: var(--header-h);
  background: var(--bg-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-4);
  padding-top: max(var(--sp-2), env(safe-area-inset-top));
  gap: var(--sp-2);
  z-index: 10;
  flex-shrink: 0;
}
.header-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-search {
  padding: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

/* Chat panel (right side) */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  min-width: 0;
}
.chat-header { flex-shrink: 0; }
/* Post cards (blog, board, resume) */
.post-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  max-width: 600px;
  transition: box-shadow var(--duration-fast) var(--ease);
}
.post-card:hover { box-shadow: var(--shadow-md); }
.post-card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--sp-2);
  color: var(--text-primary);
}
.post-card-body {
  font-size: var(--text-base);
  line-height: var(--line-relaxed);
  color: var(--text-primary);
}
.post-card-price {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--accent);
  margin-top: var(--sp-2);
}
.post-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Post input form (for blog/board spaces) */
.post-form {
  padding: 8px 12px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.post-form input, .post-form textarea, .post-form select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-input);
  outline: none;
  box-sizing: border-box;
  height: 34px;
  margin: 0;
  min-width: 0;
}
.post-form textarea { min-height: 56px; height: auto; resize: vertical; }
.post-form input:focus, .post-form textarea:focus, .post-form select:focus { border-color: var(--accent); }
.post-form .form-row { display: flex; gap: 6px; align-items: center; }
.post-form .form-row > * { flex: 1; min-width: 0; }
.post-form .form-row > .currency-select { flex: none; width: 80px; }
.post-form .form-bottom { display: flex; align-items: center; flex-wrap: wrap; }
.post-form .form-bottom .btn { margin-left: auto; flex-shrink: 0; }

/* Post comments */
.post-comments { margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.post-comment { display: flex; gap: var(--sp-2); padding: var(--sp-2) 0; }
.post-comment-content { flex: 1; min-width: 0; }
.post-comment-author { font-size: var(--text-sm); font-weight: 600; margin-right: var(--sp-2); }
.post-comment-text { font-size: var(--text-sm); color: var(--text-primary); }
.post-comment-time { font-size: var(--text-xs); color: var(--text-tertiary); margin-left: var(--sp-2); }
.post-comment-input { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.post-comment-input .input { flex: 1; min-height: 36px; padding: 6px 12px; font-size: var(--text-sm); }

.typing-indicator {
  padding: 4px 16px; font-size: 13px; color: var(--text-secondary);
  display: flex; align-items: center;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary);
  animation: typingBounce .6s infinite alternate;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce { from { opacity: .3; transform: translateY(0); } to { opacity: 1; transform: translateY(-3px); } }

.chat-search {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-search .input { flex: 1; min-height: 36px; padding: 6px 12px; font-size: var(--text-sm); }
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.messages::-webkit-scrollbar { width: 4px; }

/* Message row — wraps bubble + meta */
.msg-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
  max-width: 100%;
}
.msg-row.out { align-items: flex-end; }
.msg-row.in { align-items: flex-start; }

/* Input bar */
.input-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  padding-bottom: max(var(--sp-2), env(safe-area-inset-bottom));
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ═══════════ COMPONENTS ═══════════ */

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--duration-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: var(--text-base);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-md);
  min-height: var(--touch-min);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }

.btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
}
.btn-icon:hover { background: var(--bg-hover); }
.btn-icon:active { background: var(--bg-active); }

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); }

/* Input */
.input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease);
  min-height: var(--touch-min);
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-tertiary); }

.input-chat {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-input);
  border: none;
  border-radius: var(--r-xl);
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text-primary);
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: var(--line-normal);
  direction: auto;
  unicode-bidi: plaintext;
}
.input-chat::placeholder { color: var(--text-tertiary); }

/* Avatar */
.avatar {
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-lg);
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: var(--avatar-sm); height: var(--avatar-sm); font-size: var(--text-sm); border-radius: var(--r-sm); }
.avatar-lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: var(--text-xl); border-radius: var(--r-lg); }

/* Space item (sidebar) */
.space-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
  min-height: 60px;
}
.space-item:hover { background: var(--bg-hover); }
.space-item:active { background: var(--bg-active); }
.space-item.active { background: var(--bg-active); }
.space-item .name { font-weight: 500; font-size: var(--text-base); color: var(--text-primary); }
.space-item .sub { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }
.space-item .meta { margin-left: auto; text-align: right; flex-shrink: 0; }
.space-item .time { font-size: var(--text-xs); color: var(--text-tertiary); }
.space-item .badge {
  background: var(--accent);
  color: white;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--r-full);
  margin-top: 4px;
  display: inline-block;
}

/* Message bubble */
.bubble {
  max-width: min(80%, 520px);
  min-width: 48px;
  padding: 6px 12px;
  border-radius: var(--r-bubble);
  font-size: var(--text-base);
  line-height: var(--line-normal);
  position: relative;
  width: fit-content;
}
.bubble-in {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}
.bubble-out {
  align-self: flex-end;
  background: var(--bg-bubble-out);
  color: var(--text-bubble-out);
  border-bottom-right-radius: 6px;
}
.bubble .msg-text {
  unicode-bidi: plaintext;
  direction: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble .msg-text code {
  background: rgba(0,0,0,.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.bubble-in .msg-text code { background: var(--bg-tertiary); }
.bubble .msg-text pre {
  background: #1c1c1e;
  color: #f5f5f7;
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  margin: var(--sp-1) 0;
  line-height: 1.5;
}
.bubble .msg-text a { color: inherit; text-decoration: underline; opacity: .85; }
.bubble-in .msg-text a { color: var(--text-link); opacity: 1; }
.bubble-meta {
  font-size: 11px;
  opacity: .5;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 4px 0 -4px 12px;
}
.bubble-in .bubble-meta { opacity: .4; }
.bubble-out .bubble-meta { opacity: .7; }
.check { color: rgba(255,255,255,.8); }

/* File card */
.file-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-hover);
  border-radius: var(--r-md);
  margin: var(--sp-1) 0;
  max-width: 280px;
}
.file-card .file-icon { font-size: 32px; flex-shrink: 0; }
.file-card .file-info { flex: 1; min-width: 0; }
.file-card .file-name { font-size: var(--text-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .file-size { font-size: var(--text-xs); color: var(--text-tertiary); }
.file-card .file-dl { color: var(--accent); font-size: var(--text-sm); font-weight: 500; flex-shrink: 0; }

/* Image preview in bubble */
.bubble img.preview {
  max-width: 100%;
  max-height: 300px;
  cursor: pointer;
  display: block;
}
.bubble-out img.preview { border-radius: 14px 14px 2px 14px; }
.bubble-in img.preview  { border-radius: 14px 14px 14px 2px; }
.bubble video.preview, .bubble audio.preview {
  max-width: 100%;
  border-radius: var(--r-sm);
  margin: var(--sp-1) 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--duration-fast) var(--ease);
}
.modal {
  background: var(--bg-primary);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  width: 340px;
  max-width: 90%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--duration-normal) var(--ease-spring);
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--sp-4);
}
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }
.modal .btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-md);
  min-height: 38px;
}
.modal .btn-primary { padding: var(--sp-2) var(--sp-5); min-height: 38px; font-size: var(--text-sm); }

/* Login screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: var(--sp-5);
  background: var(--bg-secondary);
}
.login-logo {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.5px;
}
.login-sub { color: var(--text-secondary); font-size: var(--text-sm); }
.login-input { width: 300px; }
.login-error { color: var(--red); font-size: var(--text-sm); height: 20px; }

/* Settings / Profile */
.settings-screen { padding: var(--sp-6); max-width: 500px; margin: 0 auto; }
.settings-section { margin-bottom: var(--sp-6); }
.settings-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: var(--sp-2);
  padding: 0 var(--sp-4);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  min-height: var(--touch-min);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}
.settings-row:hover { background: var(--bg-hover); }
.settings-row:first-child { border-radius: var(--r-md) var(--r-md) 0 0; }
.settings-row:last-child { border-radius: 0 0 var(--r-md) var(--r-md); border-bottom: none; }
.settings-row:only-child { border-radius: var(--r-md); }
.settings-label { font-size: var(--text-base); font-weight: 400; }
.settings-value { font-size: var(--text-base); color: var(--text-tertiary); }
.settings-chevron { color: var(--text-tertiary); font-size: var(--text-sm); }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  gap: var(--sp-2);
}
.empty-state .icon { font-size: 48px; opacity: .4; }
.empty-state .text { font-size: var(--text-sm); }

/* Language switcher */
.lang-switch { display: flex; gap: var(--sp-1); }
.lang-btn {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--duration-fast) var(--ease);
}
.lang-btn.active { background: var(--accent); color: white; }
.lang-btn:not(.active) { background: var(--bg-tertiary); color: var(--text-secondary); }

/* Toast notification */
.toast {
  position: fixed;
  top: var(--sp-4);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 400;
  animation: slideDown var(--duration-normal) var(--ease-spring);
}

/* Call screen */
.call-screen {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.call-screen.video-call .call-bg { display: none; }
.call-screen.video-call { background: transparent; pointer-events: none; }
.call-screen.video-call .call-content { pointer-events: auto; position: fixed; bottom: 40px; left: 0; right: 0; }
.call-screen.video-call .call-name, .call-screen.video-call .call-status { text-shadow: 0 1px 8px rgba(0,0,0,.8); }
.call-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.call-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
  color: white; text-align: center;
}
.call-name { font-size: var(--text-2xl); font-weight: 600; }
.call-status { font-size: var(--text-base); opacity: .7; }
.call-actions {
  display: flex; gap: var(--sp-6); margin-top: var(--sp-10);
}
.call-btn {
  width: 60px; height: 60px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: white; transition: transform var(--duration-fast) var(--ease);
}
.call-btn:active { transform: scale(.9); }
.call-mute { background: rgba(255,255,255,.2); }
.call-video { background: rgba(255,255,255,.2); }
.call-answer { background: var(--green); }
.call-hangup { background: var(--red); }

/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg-primary);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 140px;
  animation: scaleIn var(--duration-fast) var(--ease-spring);
}
.ctx-reactions {
  display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.ctx-react-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; border-radius: var(--r-sm); cursor: pointer;
  transition: transform var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.ctx-react-btn:hover { background: var(--bg-hover); transform: scale(1.2); }
.ctx-react-btn:active { transform: scale(.9); }
.bubble-reactions {
  display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap;
}
.bubble-reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--bg-secondary); font-size: 14px; cursor: pointer;
  border: 1px solid var(--border);
}
.bubble-reaction:hover { background: var(--bg-hover); }
.bubble-reaction .count { font-size: 11px; color: var(--text-secondary); }
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--duration-fast) var(--ease);
}
.ctx-menu-item:hover { background: var(--bg-hover); }
.ctx-menu-item:active { background: var(--bg-active); }

/* ═══════════ MESSAGE MENU BUTTON (⋮) ═══════════ */

.msg-menu-btn {
  position: absolute; top: 4px; right: 4px;
  cursor: pointer; padding: 4px; border-radius: 50%;
  line-height: 0; opacity: 0;
  transition: opacity .15s, background .15s;
  color: var(--text-secondary); z-index: 1;
}
.msg-menu-btn:hover { opacity: 1 !important; background: var(--bg-hover); }
.msg-menu-btn:active { background: var(--bg-active); }
.bubble-out .msg-menu-btn { color: rgba(255,255,255,.7); }
.bubble-out .msg-menu-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.bubble-in .msg-menu-btn { color: var(--text-tertiary); }
.bubble-in .msg-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Desktop: show on parent hover */
.bubble:hover > .msg-menu-btn,
[style*="position: relative"]:hover > .msg-menu-btn,
[style*="position:relative"]:hover > .msg-menu-btn { opacity: 0.5; }

/* Mobile: always visible, larger touch target */
@media (max-width: 768px) {
  .msg-menu-btn { opacity: 0.7 !important; padding: 8px; top: 2px; right: 2px; }
}

/* ═══════════ ANIMATIONS ═══════════ */

@keyframes fadeIn { from { opacity: 0; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } }
@keyframes slideDown { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ═══════════ RESPONSIVE ═══════════ */

@media (max-width: 768px) {
  .sidebar { width: 100%; flex: 1; }
  .layout { flex-direction: column; position: relative; }
  .chat-panel {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: none;
    flex-direction: column;
    background: var(--bg-primary);
  }
  .chat-panel.open { display: flex; }
  .messages { padding: 10px 8px; }
  .bubble { max-width: 85%; }
  .bubble-meta { padding-right: 0; }
  .space-item { padding: var(--sp-3) var(--sp-4); }
}

@media (min-width: 769px) {
  .chat-panel { display: flex; flex-direction: column; }
  .chat-header { display: flex; }
  .back-btn { display: none !important; }
}
