*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

:root {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --border: #475569;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Screens */
#loginScreen { overflow-y: auto; }
.app-download-card { margin-top: 24px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-secondary); text-align: left; }
.app-download-icon { float: right; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--bg-tertiary); color: var(--primary-hover); font-size: 24px; }
.app-download-card h2 { font-size: 18px; margin-bottom: 6px; }
.app-download-card p { color: var(--text-muted); font-size: 14px; }
.app-download-button { display: block; margin: 16px 0 10px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--primary); color: white; text-decoration: none; text-align: center; font-weight: 600; }
.app-download-button:hover { background: var(--primary-hover); }
.app-download-card small { display: block; color: var(--text-muted); line-height: 1.5; font-size: 12px; }
.sidebar-app-install { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.screen { display: none; height: 100%; width: 100%; }
.screen.active { display: flex; }

/* Login */
.login-container {
  margin: auto;
  padding: 2rem;
  text-align: center;
  width: 100%;
  max-width: 400px;
}

.app-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  color: var(--text-muted);
  margin: 0.5rem 0 2rem;
}

#loginForm input[type="text"],
#loginForm input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#loginForm input[type="password"] {
  margin-top: 0.75rem;
}

#loginForm input[type="text"]:focus,
#loginForm input[type="password"]:focus {
  border-color: var(--primary);
}

.color-picker {
  margin: 1.25rem 0;
  text-align: left;
}

.color-picker label {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-option {
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}

.color-option.selected {
  border-color: var(--text);
  transform: scale(1.15);
}

/* RGB color picker */
.color-rgb-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
#colorRgbInput {
  width: 48px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.color-preview {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.color-hex {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: monospace;
}
.color-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--primary-hover); }

/* Chat Layout */
.chat-layout {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 { font-size: 1rem; }

/* Online list */
.online-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.online-list li {
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-links {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
.sidebar-links h4 {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-links a {
  display: block;
  padding: 6px 0;
  color: var(--primary-hover);
  text-decoration: none;
  font-size: 0.85rem;
}
.sidebar-links a:hover {
  text-decoration: underline;
}

.device-badge {
  font-size: 0.75rem;
  margin-left: 2px;
}

/* Away (자리비움): user is backgrounded or recently disconnected but still
   within the grace window — dimmed, with a muted "자리비움" label. */
.online-list li.is-away {
  opacity: 0.55;
}
.away-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 4px;
  flex-shrink: 0;
}

/* Chat Main */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.chat-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.notify-btn {
  font-size: 1.2rem;
  transition: opacity 0.2s;
}

.member-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-icon:hover { background: var(--bg-tertiary); }

/* Unified header icon buttons — all the same size as the "?" button.
   Higher specificity (.chat-header .header-circle-btn) so it wins over the
   per-button rules (.help-header-btn / .dccon-list-header-btn). */
.chat-header .header-circle-btn {
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.3px;
  padding: 0;
  margin: 0;
  text-align: center;
  background: none;
  color: var(--text-muted);
  flex-shrink: 0;
  overflow: hidden;
}
.chat-header .header-circle-btn:hover {
  border-color: var(--primary);
  color: var(--accent-text);
  background: var(--bg-tertiary);
}

.menu-btn { display: none; }

.hidden { display: none !important; }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.load-more-btn {
  align-self: center;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.2s, color 0.2s;
}

.load-more-btn:hover { background: var(--border); color: var(--text); }
.load-more-btn:disabled { opacity: 0.5; cursor: default; }

.msg {
  max-width: 75%;
  padding: 8px 14px;
  border-radius: var(--radius);
  word-wrap: break-word;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.own {
  align-self: flex-end;
  background: var(--primary);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.msg.other {
  align-self: flex-start;
  background: var(--bg-secondary);
  border-bottom-left-radius: 4px;
}

.msg-username {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.msg-text {
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-text strong { font-weight: 700; }
.msg-text em { font-style: italic; }
.msg-text del { text-decoration: line-through; opacity: 0.7; }

.msg-text code {
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.875em;
}

.msg.own .msg-text code { background: rgba(255,255,255,0.15); }

.msg-text pre {
  background: rgba(0,0,0,0.3);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 4px 0;
  white-space: pre;
}

.msg.own .msg-text pre { background: rgba(255,255,255,0.12); }

.msg-text pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

.msg-text blockquote {
  border-left: 3px solid var(--text-muted);
  padding-left: 8px;
  margin: 4px 0;
  opacity: 0.85;
}

.msg.own .msg-text blockquote { border-left-color: rgba(255,255,255,0.4); }

/* Music Share Card (chat message) */
.msg-music-share {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
}
.music-share-caption {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.msg.own .music-share-caption { color: rgba(255,255,255,0.85); }
.music-share-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  align-items: center;
}
.music-share-card:hover { border-color: var(--primary); background: var(--bg); }
.msg.own .music-share-card {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.3);
  color: var(--text);
}
.msg.own .music-share-card:hover { background: rgba(255,255,255,0.28); }
.music-share-cover {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}
.music-share-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
}
.music-share-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.music-share-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-share-artist {
  font-size: 0.82rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-share-album {
  font-size: 0.72rem;
  opacity: 0.65;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-share-duration {
  font-size: 0.72rem;
  opacity: 0.7;
  margin-top: 2px;
}

/* Music Status Badge in User List */
.online-list li.has-music {
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.online-user-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.online-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.user-music {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 16px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  min-width: 0;
  max-width: calc(100% - 16px);
}
.user-music:hover { color: var(--accent-text); }
.music-note { font-size: 0.85rem; flex-shrink: 0; }
.music-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Music Settings Modal */
.music-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.music-modal.hidden { display: none; }
.music-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 360px;
  max-width: 92vw;
}
.music-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.music-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}
.music-body { padding: 16px; }
.music-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 12px 0;
  line-height: 1.4;
}
.music-label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.music-label input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  box-sizing: border-box;
}
.music-label input:focus { border-color: var(--primary); outline: none; }
.music-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.music-save-btn, .music-clear-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.music-save-btn { background: var(--primary); color: var(--text); }
.music-save-btn:hover { background: var(--primary-hover); }
.music-clear-btn { background: var(--bg-tertiary); color: var(--text); }
.music-clear-btn:hover { background: var(--danger); color: var(--text); }
.music-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0;
}
.music-hint a { color: var(--accent-text); }

/* Drag & Drop overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(99, 102, 241, 0.18);
  backdrop-filter: blur(4px);
  border: 4px dashed var(--primary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: dropOverlayIn 0.12s ease;
}
.drop-overlay.hidden { display: none; }
.drop-overlay-inner {
  background: var(--bg-secondary);
  color: var(--text);
  padding: 24px 40px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
@keyframes dropOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  align-items: center;
}
.reaction-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 1px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.4;
  transition: all 0.15s;
}
.reaction-chip:hover { border-color: var(--text); }
.reaction-chip.mine {
  background: rgba(99,102,241,0.18);
  border-color: var(--primary);
  color: var(--accent-text);
}
.reaction-count {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.85;
}
.reaction-add-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 8px;
  line-height: 1.6;
  cursor: pointer;
  display: none;
  transition: border-color 0.15s, color 0.15s;
}
.msg.reaction-add-visible .reaction-add-btn { display: inline-flex; align-items: center; }
.reaction-add-btn:hover { border-color: var(--primary); color: var(--accent-text); }
.msg.own .reaction-chip {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.3);
  color: var(--text);
}
.msg.own .reaction-chip.mine {
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.6);
}
.msg.own .reaction-add-btn { border-color: rgba(255,255,255,0.35); color: rgba(255,255,255,0.7); }
.msg.own .reaction-add-btn:hover { border-color: var(--text); color: var(--text); }

/* Reaction picker popup (floating) */
.reaction-popup {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  gap: 2px;
  z-index: 250;
  animation: reactionPopupIn 0.12s ease;
}
@keyframes reactionPopupIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.quick-reaction, .reaction-more {
  background: none;
  border: none;
  font-size: 1.3rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.12s;
}
.quick-reaction:hover, .reaction-more:hover {
  background: var(--bg-tertiary);
  transform: scale(1.15);
}
.reaction-more { font-size: 1rem; color: var(--text-muted); }

/* Emoji picker in reaction mode — visual hint */
.emoji-picker.as-reaction-picker {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.msg-time {
  font-size: 0.7rem;
  opacity: 0.6;
  text-align: right;
  margin-top: 2px;
}

.msg-file img {
  max-width: 250px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  cursor: pointer;
}

.msg-file a {
  color: var(--primary-hover);
  text-decoration: underline;
  font-size: 0.875rem;
}

.msg.own .msg-file a { color: var(--text); }

.date-divider {
  align-self: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 16px;
  margin: 12px 0 6px;
  position: relative;
  text-align: center;
}

.date-divider::before,
.date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40px;
  height: 1px;
  background: var(--border);
}

.date-divider::before { right: 100%; margin-right: 8px; }
.date-divider::after { left: 100%; margin-left: 8px; }

.system-msg {
  align-self: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border-radius: 20px;
}

/* Typing indicator */
.typing-indicator {
  padding: 4px 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Message form */
.message-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0.6rem 0.75rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.message-form textarea {
  flex: 1;
  min-width: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  line-height: 1.4;
}

.message-form textarea:focus { border-color: var(--primary); }

.msg-form-tools {
  position: relative;
  flex-shrink: 0;
  align-self: center;
}

.tools-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  line-height: 1;
}
.tools-toggle-btn:hover { background: var(--bg-tertiary); }
.tools-toggle-btn.active { transform: rotate(45deg); background: var(--bg-tertiary); }

.tools-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
  min-width: 160px;
  animation: toolsPanelIn 0.15s ease;
}
@keyframes toolsPanelIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tools-panel.hidden { display: none; }

.tools-panel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: var(--radius);
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.15s;
}
.tools-panel-item:hover { background: var(--bg-tertiary); }
.tools-panel-icon { font-size: 1.4rem; }

/* Roulette Modal */
/* GIF (Tenor) Picker Modal */
.gif-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gif-modal.hidden { display: none; }
.gif-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 480px;
  max-width: 92vw;
  height: 70vh;
  display: flex;
  flex-direction: column;
}
.gif-header {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.gif-search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
.gif-search-input:focus { border-color: var(--primary); }
.gif-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 8px;
}
.gif-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 120px;
  gap: 6px;
  align-content: start;
}
.gif-result-item {
  position: relative;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.gif-result-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gif-result-item:hover { outline: 2px solid var(--primary); }
.gif-result-item.gif-result-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-word;
}
.gif-loading, .gif-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.gif-footer {
  padding: 6px 12px;
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
@media (max-width: 480px) {
  .gif-modal-content { width: 100vw; max-width: 100vw; height: 80vh; border-radius: 0; }
  .gif-results { grid-auto-rows: 100px; }
}
@media (min-width: 600px) {
  .gif-results { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 130px; }
}

.roulette-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.roulette-modal.hidden { display: none; }
.roulette-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 340px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.roulette-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.roulette-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}
.roulette-body { padding: 16px; }
.roulette-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.roulette-label select {
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.roulette-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.roulette-items input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  box-sizing: border-box;
}
.roulette-items input:focus { border-color: var(--primary); outline: none; }
.roulette-spin-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.roulette-spin-btn:hover { background: var(--primary-hover); }
.roulette-spin-btn:disabled { opacity: 0.5; cursor: default; }

/* Roulette Spin Overlay */
.roulette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.roulette-overlay.hidden { display: none; }
.roulette-spin-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 32px;
  min-width: 260px;
  max-width: 90vw;
  text-align: center;
}
.roulette-spin-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.roulette-spin-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.roulette-slot {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: all 0.08s ease;
  color: var(--text-muted);
}
.roulette-slot.active {
  background: var(--primary);
  color: var(--text);
  font-weight: 700;
  transform: scale(1.05);
}
.roulette-slot.winner {
  background: #f59e0b;
  color: var(--text);
  font-weight: 700;
  transform: scale(1.1);
  animation: rouletteWin 0.4s ease 3;
}
@keyframes rouletteWin {
  0%, 100% { transform: scale(1.1); }
  50% { transform: scale(1.2); }
}
.roulette-spin-result {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 12px;
  animation: fadeIn 0.3s ease;
}
.roulette-spin-result.hidden { display: none; }

.btn-send {
  padding: 8px 18px;
  border: none;
  border-radius: 24px;
  background: var(--primary);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.btn-send:hover { background: var(--primary-hover); }

/* File preview */
.file-preview {
  padding: 8px 1rem;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.file-preview .remove-file {
  cursor: pointer;
  color: var(--danger);
  font-weight: 700;
  margin-left: auto;
}

/* Markdown live preview (above input) */
.bot-command-preview {
  padding: 8px 1rem;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  flex-shrink: 0;
}
.bot-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.85rem; }
.bot-preview-header code, .bot-preview-action, .bot-preview-count { color: var(--text-muted); font-size: 0.72rem; }
.bot-preview-action { margin: 4px 0; }
.bot-preview-body { max-height: 60px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85rem; }
.bot-preview-count { text-align: right; margin-top: 3px; }
.bot-preview-count.over-limit { color: #f87171; }
.md-preview {
  padding: 6px 1rem 8px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  max-height: 120px;
  overflow-y: auto;
}
.md-preview.hidden { display: none; }
.md-preview-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  letter-spacing: 0.5px;
}
.md-preview-body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.md-preview-body code {
  background: rgba(0,0,0,0.3);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.875em;
}
.md-preview-body pre {
  background: rgba(0,0,0,0.3);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 4px 0;
}
.md-preview-body pre code { background: none; padding: 0; }
.md-preview-body blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 8px;
  margin: 4px 0;
  opacity: 0.85;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

  .sidebar.open { left: 0; }
  .sidebar.open + .sidebar-overlay { display: block; }

  .menu-btn { display: block; }
  #toggleSidebar { display: block; }

  .chat-header {
    gap: 6px;
    padding: 0.5rem 0.6rem;
    min-height: 44px;
    flex-wrap: nowrap;
  }

  .chat-header h3 { font-size: 0.9rem; white-space: nowrap; }

  .member-count { font-size: 0.7rem; margin-left: auto; }

  .btn-icon { font-size: 1.2rem; padding: 2px 5px; }
  .help-header-btn { width: 24px; height: 24px; font-size: 0.85rem; }
  .notify-btn { font-size: 1rem; }

  .btn-logout { font-size: 0.65rem; padding: 4px 8px; }

  .msg { max-width: 85%; }

  .message-form { gap: 4px; padding: 0.5rem; }
  .tools-toggle-btn { width: 32px; height: 32px; font-size: 1rem; }
  .tools-panel { min-width: 140px; }
  .tools-panel-item { padding: 8px 6px; font-size: 0.7rem; }
  .tools-panel-icon { font-size: 1.2rem; }
  .btn-send { padding: 7px 12px; font-size: 0.8rem; }

  .login-container { padding: 1.5rem; }
  .app-title { font-size: 2rem; }
}

@media (min-width: 769px) {
  #toggleSidebar { display: none; }
}

/* Image Viewer Modal */
.image-viewer {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}

.image-viewer.active {
  display: flex;
}

.image-viewer img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
  cursor: zoom-in;
  transition: transform 0.2s ease;
  transform-origin: center center;
}
.image-viewer img.zoomed {
  transform: scale(2.5);
  cursor: zoom-out;
  border-radius: 0;
}

.image-viewer-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 1001;
  line-height: 1;
}

/* Upload Progress */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 1rem;
  background: var(--bg-tertiary);
}

.upload-progress-inner {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.upload-progress span {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

@keyframes uploadPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.upload-progress:not(.hidden) {
  animation: uploadPulse 1.5s ease-in-out infinite;
}

/* Logout Button */
.btn-logout {
  background: var(--danger);
  color: var(--text);
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
}

.btn-logout:hover { background: #dc2626; transform: scale(1.05); }

/* Help Button (header) */
.help-header-btn {
  font-size: 1rem;
  font-weight: 700;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  padding: 0;
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s;
}

.help-header-btn:hover { border-color: var(--primary); color: var(--accent-text); background: var(--bg-tertiary); }

/* Help Modal */
.help-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.help-modal.active { display: flex; }

.help-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

.help-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.help-modal-header h3 { font-size: 1rem; }

.help-modal-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.help-modal-body {
  padding: 1rem 1.25rem 1.5rem;
}

.help-modal-body h4 {
  font-size: 0.85rem;
  color: var(--primary-hover);
  margin: 1rem 0 0.5rem;
}

.help-modal-body h4:first-child { margin-top: 0; }

.help-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.4;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.help-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: middle;
}

.help-table td:first-child {
  color: var(--text-muted);
  white-space: nowrap;
  width: 45%;
}

.help-table kbd {
  background: var(--bg-tertiary);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

.help-table code {
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  font-size: 0.8rem;
}

/* Emoji Picker */
.emoji-mode-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.emoji-mode-tabs button, .custom-gif-upload { padding: 6px 12px; color: var(--text); border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; }
.emoji-mode-tabs button.active { color: var(--accent-text); border-color: var(--primary); }
.custom-gif-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.75rem; color: var(--text-muted); }
.custom-gif-hint { margin: 6px 0; font-size: 0.75rem; color: var(--text-muted); }
.custom-gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.custom-gif-card { position: relative; min-width: 0; background: var(--bg-tertiary); border-radius: 6px; }
.custom-gif-use { width: 100%; padding: 5px; background: none; border: 0; color: var(--text); cursor: pointer; }
.custom-gif-use img { width: 100%; height: 66px; object-fit: contain; border-radius: 4px; }
.custom-gif-use span { display: block; font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-gif-delete { position: absolute; right: 1px; top: 1px; border: 0; border-radius: 50%; background: #0f172acc; color: white; width: 23px; height: 23px; cursor: pointer; }
.custom-gif-reaction { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; }
.emoji-picker {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.emoji-search-wrap {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  padding-bottom: 6px;
  z-index: 2;
}
.emoji-search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}
.emoji-search-input:focus { border-color: var(--primary); }
.emoji-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.emoji-picker-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.emoji-tab {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}

.emoji-tab.active { background: var(--bg-tertiary); }
.emoji-tab:hover { background: var(--bg-tertiary); }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 2px;
  justify-content: center;
}

.emoji-item {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: 6px;
  border: none;
  background: none;
  transition: background 0.15s;
}

.emoji-item:hover { background: var(--bg-tertiary); }

/* Send Button Loading */
.btn-send.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn-send.loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: sendSpin 0.6s linear infinite;
  top: 50%; left: 50%;
  margin: -9px 0 0 -9px;
}

@keyframes sendSpin {
  to { transform: rotate(360deg); }
}


/* Dccon Picker */
.dccon-picker {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.dccon-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  flex-shrink: 0;
}

.dccon-tab {
  width: 36px; height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 2px;
  background: none;
  overflow: hidden;
}

.dccon-tab img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.dccon-tab.active { background: var(--bg-tertiary); }
.dccon-tab:hover { background: var(--bg-tertiary); }

.dccon-tab-add {
  width: 36px; height: 36px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dccon-tab-add:hover { border-color: var(--primary); color: var(--accent-text); }

.dccon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 60px);
  gap: 4px;
  justify-content: center;
  overflow-y: auto;
  flex: 1;
}

.dccon-item {
  width: 60px; height: 60px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  padding: 4px;
  transition: background 0.15s;
}

.dccon-item:hover { background: var(--bg-tertiary); }

.dccon-item img {
  width: 100%; height: 100%;
  object-fit: contain;
}

.dccon-add-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 8px;
  flex: 1;
  overflow: hidden;
}

.dccon-add-form p {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.dccon-add-row {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 280px;
}

.dccon-add-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.dccon-add-row input:focus { border-color: var(--primary); }

.dccon-add-row button {
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.dccon-add-row button:disabled {
  opacity: 0.5;
  cursor: default;
}

.dccon-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 0.85rem;
  flex: 1;
}

/* Claude Bot Message */
.msg.bot {
  background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(245,158,11,0.05));
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-md);
  align-self: flex-start;
  max-width: 85%;
}
.msg.bot.evil {
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(239,68,68,0.05));
  border: 1px solid rgba(239,68,68,0.25);
}
.msg-claude-q {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 2px 0 6px;
  border-bottom: 1px solid rgba(245,158,11,0.15);
  margin-bottom: 6px;
}
.msg.bot.evil .msg-claude-q {
  border-bottom-color: rgba(239,68,68,0.15);
}

/* Dccon Message */
.msg-dccon {
  display: flex;
  gap: 0;
  align-items: flex-end;
}
.msg-dccon img {
  min-width: 0;
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
}
.msg-dccon.combo img {
  max-width: 100px;
  max-height: 100px;
}

/* GIF Message (Tenor) */
.msg.gif-msg {
  background: none;
  padding: 4px 0;
}
.msg-gif img {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius);
  display: block;
}

/* Emoji-only messages */
.msg.emoji-only-msg {
  background: none;
  border: none;
  padding: 4px 0;
}
.msg-text.emoji-only {
  font-size: 4rem;
  line-height: 1.2;
}

.dccon-del-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.dccon-del-btn:hover { background: rgba(239,68,68,0.15); }

/* Dccon Search Results */
.dccon-search-results {
  width: 100%;
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dccon-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  color: var(--text);
  width: 100%;
}

.dccon-search-item:hover { background: var(--bg-tertiary); }

.dccon-search-thumb {
  object-fit: contain;
  width: 36px; height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--primary);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.sticker-source-tabs { display: flex; gap: 8px; }
.sticker-source-tabs button { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; }
.sticker-source-tabs button[aria-pressed="true"] { background: var(--primary); color: white; }
.sticker-search-notice { text-align: left !important; line-height: 1.5; padding: 8px; background: var(--bg-tertiary); border-radius: 6px; }
.sticker-preview-modal { position: fixed; inset: 0; z-index: 2100; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sticker-preview-modal.hidden { display: none; }
.sticker-preview-dialog { width: min(680px, 100%); max-height: 85dvh; display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 16px; background: var(--bg-secondary); color: var(--text); }
.sticker-preview-header { display: flex; align-items: center; gap: 12px; }
.sticker-preview-header h3 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sticker-preview-header button { background: none; border: none; color: var(--text); font-size: 28px; cursor: pointer; }
#stickerPreviewStatus { color: var(--text-muted); font-size: .85rem; }
.sticker-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; overflow-y: auto; min-height: 100px; }
.sticker-preview-grid figure { margin: 0; background: var(--bg-tertiary); padding: 6px; border-radius: 8px; text-align: center; }
.sticker-preview-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.sticker-preview-grid figcaption { color: var(--text-muted); font-size: .7rem; overflow-wrap: anywhere; }
.sticker-preview-grid .sticker-image-error { border: 1px dashed var(--danger); }
.sticker-preview-dialog > button { flex-shrink: 0; }

.dccon-search-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dccon-search-info strong {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dccon-search-info span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Dccon Pack Header */
.dccon-pack-header {
  display: flex;
  align-items: center;
  padding: 2px 4px 4px;
  flex-shrink: 0;
}

.dccon-pack-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Message Hide Button */
.msg-hide-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
}

.msg {
  position: relative;
}

.msg:hover .msg-hide-btn { opacity: 0.5; }
.msg-hide-btn:hover { opacity: 1 !important; color: var(--danger); }

/* Dccon queued state (in send queue) */
.dccon-item.queued {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 6px;
  background: rgba(99,102,241,0.15);
  position: relative;
}
.dccon-count-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--primary);
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  pointer-events: none;
  min-width: 18px;
  text-align: center;
}
.dccon-send-preview img { cursor: pointer; }
.dccon-send-preview img:hover { outline: 2px solid var(--danger); outline-offset: -2px; border-radius: 4px; }

/* Dccon send bar */
.dccon-send-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.dccon-send-preview {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.dccon-send-preview img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.dccon-send-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.dccon-send-btn,
.dccon-clear-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}
.dccon-send-btn {
  background: var(--primary);
  color: var(--text);
}
.dccon-send-btn:hover { opacity: 0.85; }
.dccon-clear-btn {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.dccon-clear-btn:hover { background: var(--border); }

/* Dccon Server Pack Management */
.dccon-manage-toggle {
  width: 100%;
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-muted);
  padding: 10px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}
.dccon-manage-toggle:hover { color: var(--text); border-color: var(--text-muted); }
.dccon-manage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.dccon-manage-list.hidden { display: none; }
.dccon-manage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}
.dccon-manage-item.in-use { border-color: var(--primary); }
.dccon-manage-item img {
  width: 48px; height: 48px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}
.dccon-manage-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dccon-manage-info strong {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dccon-manage-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.dccon-manage-del {
  border: none;
  background: var(--danger);
  color: var(--text);
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.dccon-manage-del:hover { opacity: 0.85; }
.dccon-manage-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 10px;
}

/* Dccon Download Modal */
.dccon-dl-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.dccon-dl-modal.active { display: flex; }
.dccon-dl-modal-content {
  text-align: center;
  color: var(--text);
  padding: 40px;
}
.dccon-dl-modal-content p {
  margin: 12px 0 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.dccon-dl-sub {
  font-size: 0.85rem !important;
  font-weight: 400 !important;
  color: rgba(255,255,255,0.6) !important;
  line-height: 1.5;
}
.dccon-dl-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto;
  animation: dccon-spin 0.8s linear infinite;
}
@keyframes dccon-spin {
  to { transform: rotate(360deg); }
}

/* Update Banner */
.update-banner {
  background: #1e40af;
  color: var(--text);
  text-align: center;
  padding: 8px 36px 8px 12px;
  font-size: 0.85rem;
  position: relative;
  flex-shrink: 0;
}
.update-banner kbd {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8rem;
}
.update-banner-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.7;
}
.update-banner-close:hover { opacity: 1; }

/* Notify Tutorial */
.notify-tutorial {
  background: #065f46;
  color: var(--text);
  text-align: center;
  padding: 8px 36px 8px 12px;
  font-size: 0.85rem;
  position: relative;
  flex-shrink: 0;
}
.notify-tutorial-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.7;
}
.notify-tutorial-close:hover { opacity: 1; }

/* Dccon List Header Button */
.dccon-list-header-btn {
  font-size: 0.65rem;
  font-weight: 800;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  padding: 0;
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s;
}
.dccon-list-header-btn:hover { border-color: var(--primary); color: var(--accent-text); background: var(--bg-tertiary); }

/* Dccon List Modal */
.dccon-list-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.dccon-list-modal.active { display: flex; }
.dccon-list-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dccon-list-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dccon-list-modal-header h3 { font-size: 1rem; }
.dccon-list-modal-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.dccon-list-modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dccon-list-pack {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.dccon-list-pack-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
}
.dccon-list-pack-header img {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.dccon-list-pack-header .pack-info {
  flex: 1;
  min-width: 0;
}
.dccon-list-pack-header .pack-info strong {
  font-size: 0.85rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dccon-list-pack-header .pack-info span {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.dccon-list-pack-header .pack-toggle {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.dccon-list-save {
  flex-shrink: 0;
  padding: 7px 9px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--accent-text);
  font-size: 0.75rem;
  cursor: pointer;
}
.dccon-list-save:disabled { opacity: 0.6; cursor: default; }
.dccon-list-pack-grid {
  display: none;
  grid-template-columns: repeat(auto-fill, 56px);
  gap: 4px;
  padding: 8px;
  justify-content: center;
}
.dccon-list-pack.open .dccon-list-pack-grid {
  display: grid;
}
.dccon-list-pack.open .pack-toggle { transform: rotate(180deg); }
.dccon-list-pack-grid img {
  width: 56px; height: 56px;
  object-fit: contain;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}
.dccon-list-pack-grid img:hover { transform: scale(1.15); }

@media (max-width: 768px) {
  .dccon-list-header-btn { width: 24px; height: 24px; font-size: 0.55rem; }
}
