:root {
  /* Backgrounds */
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #232428;
  --bg-input: #1e1f22;
  --bg-input-bar: #383a40;
  --bg-hover: #35373c;
  --bg-active: #404249;
  --bg-message-hover: #2e3035;
  --bg-context-menu: #111214;

  /* Text */
  --text-primary: #dbdee1;
  --text-heading: #f2f3f5;
  --text-secondary: #949ba4;
  --text-tertiary: #b5bac1;
  --text-placeholder: #6d6f78;
  --text-white: #fff;

  /* Accent */
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-active: #3c45a5;
  --accent-faint: rgba(88, 101, 242, 0.15);

  /* Links */
  --link: #00a8fc;

  /* Borders */
  --border: #1e1f22;
  --border-subtle: #404249;

  /* Status */
  --error: #fa7775;
  --error-bg: rgba(248, 65, 65, 0.1);
  --danger: #da373c;
  --danger-hover: #a12d31;
  --error-dark: #f04747;
  --success: #43b581;

  /* Shadows */
  --shadow-heavy: rgba(0, 0, 0, 0.5);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --shadow-light: rgba(0, 0, 0, 0.2);
  --overlay: rgba(0, 0, 0, 0.7);
  --overlay-medium: rgba(0, 0, 0, 0.6);
  --overlay-light: rgba(0, 0, 0, 0.5);
  --overlay-lighter: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family:
    "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ── Login screen ── */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
}

#app.login-view {
  width: 100%;
  max-width: 480px;
  padding: 1rem;
}

.login-box {
  background: var(--bg-primary);
  border-radius: 4px;
  padding: 2rem;
  box-shadow: 0 2px 10px var(--shadow-medium);
  text-align: center;
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.25rem;
}

.login-box .subtitle {
  color: var(--text-tertiary);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.login-box .error {
  background: var(--error-bg);
  color: var(--error);
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  text-align: left;
}

.login-box .field {
  text-align: left;
  margin-bottom: 1.25rem;
}

.login-box label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.login-box label.required::after {
  content: " *";
  color: var(--error);
}

.login-box input {
  width: 100%;
  padding: 0.625rem;
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: none;
  border-radius: 3px;
  outline: none;
  transition: box-shadow 0.15s;
}

.login-box input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.login-box input::placeholder {
  color: var(--text-placeholder);
}

.login-box button {
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  background: var(--accent);
  color: var(--text-white);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.login-box button:hover {
  background: var(--accent-hover);
}

.login-box button:active {
  background: var(--accent-active);
}

/* ── Chat layout ── */

.chat-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar / channel list */
.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--shadow-light);
}

.channel-list-header {
  padding: 0.5rem 0.75rem 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.add-channel-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}

.add-channel-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.5rem;
}

.channel-item {
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
}

.channel-item:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.channel-item::before {
  content: "# ";
  font-weight: 600;
}

.channel-item.active {
  background: var(--bg-active);
  color: var(--text-heading);
}

/* User panel at sidebar bottom */
.user-panel {
  padding: 0.5rem 0.5rem;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.user-panel .user-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
}

.user-panel .user-tag:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-white);
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-panel .username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-panel .logout-btn {
  font-family: inherit;
  font-size: 0.75rem;
  background: none;
  color: var(--text-secondary);
  border: none;
  padding: 0.25rem 0.4rem;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

.user-panel .logout-btn:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

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

.chat-header {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--shadow-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-header .hash {
  color: var(--text-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.chat-messages-inner {
  padding: 0 1rem;
}

.chat-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 1rem;
}

.chat-empty h3 {
  font-size: 1.1rem;
  color: var(--text-heading);
  margin-bottom: 0.25rem;
}

.chat-empty p {
  font-size: 0.85rem;
}

/* Messages */
.message {
  padding: 0.125rem 0;
  display: flex;
  gap: 1rem;
  line-height: 1.375;
  position: relative;
}

.message:hover {
  background: var(--bg-message-hover);
}

.message .msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-white);
  flex-shrink: 0;
  margin-top: 0.125rem;
  overflow: hidden;
}

.message .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message .msg-body {
  flex: 1;
  min-width: 0;
}

.message .msg-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.message .msg-username {
  font-weight: 600;
  color: var(--text-heading);
  font-size: 0.9rem;
}

.message .msg-timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.message .msg-content {
  color: var(--text-primary);
  font-size: 0.9rem;
  word-wrap: break-word;
}

.message .msg-media {
  margin-top: 0.25rem;
}

.message .msg-media img {
  max-width: 400px;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  margin-top: 0.25rem;
}

.message .msg-reply-count {
  font-size: 0.75rem;
  color: var(--link);
  cursor: pointer;
  margin-top: 0.125rem;
}

.message .msg-reply-count:hover {
  text-decoration: underline;
}

/* Typing indicator */
.typing-indicator {
  padding: 0 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  height: 1.25rem;
  line-height: 1.25rem;
  flex-shrink: 0;
}

/* Message input */
.chat-input-bar {
  padding: 0 1rem 1.5rem;
  flex-shrink: 0;
}

.chat-input-wrap {
  background: var(--bg-input-bar);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
}

.chat-input-wrap textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  resize: none;
  max-height: 200px;
  line-height: 1.375;
}

.chat-input-wrap textarea::placeholder {
  color: var(--text-placeholder);
}

.chat-input-wrap .attach-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.chat-input-wrap .attach-btn:hover {
  color: var(--text-primary);
}

/* Upload preview */
.upload-preview {
  padding: 0.5rem 1rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.upload-preview-item {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-input);
}

.upload-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview-item .upload-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-white);
  font-size: 0.8rem;
}

.upload-preview-item .remove-upload {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.upload-preview-item .remove-upload:hover {
  background: var(--error);
  color: var(--text-white);
}

/* Drag-and-drop overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: var(--accent-faint);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
}

/* Thread panel */
.thread-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.thread-header {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.thread-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  line-height: 1;
  border-radius: 3px;
}

.thread-close:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.thread-messages .chat-messages-inner {
  padding: 0 1rem;
}

.thread-divider {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.thread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.thread-input-bar {
  padding: 0 1rem 1rem;
  flex-shrink: 0;
}

.thread-panel .message .msg-media img {
  max-width: 300px;
  max-height: 200px;
}

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--bg-primary);
  border-radius: 8px;
  width: 440px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px var(--shadow-heavy);
}

.modal-header {
  padding: 1rem 1rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  line-height: 1;
  border-radius: 3px;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

.modal-body {
  padding: 0.75rem 1rem;
}

.modal-body .field {
  margin-bottom: 1rem;
}

.modal-body label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.modal-body input[type="text"],
.modal-body input[type="password"] {
  width: 100%;
  padding: 0.625rem;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: none;
  border-radius: 3px;
  outline: none;
  transition: box-shadow 0.15s;
}

.modal-body input[type="text"]:focus,
.modal-body input[type="password"]:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.modal-body input[type="text"]::placeholder,
.modal-body input[type="password"]::placeholder {
  color: var(--text-placeholder);
}

.modal-body p {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.modal-footer {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-cancel {
  font-family: inherit;
  font-size: 0.9rem;
  background: none;
  color: var(--text-primary);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 3px;
  cursor: pointer;
}

.modal-cancel:hover {
  text-decoration: underline;
}

.modal-confirm {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  color: var(--text-white);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.modal-confirm:hover {
  background: var(--accent-hover);
}

.modal-confirm.danger {
  background: var(--danger);
}

.modal-confirm.danger:hover {
  background: var(--danger-hover);
}

/* ── Context menu ── */

.context-menu {
  position: fixed;
  background: var(--bg-context-menu);
  border-radius: 4px;
  padding: 0.375rem;
  min-width: 140px;
  box-shadow: 0 4px 12px var(--shadow-heavy);
  z-index: 60;
}

.context-menu-item {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  border-radius: 3px;
  cursor: pointer;
}

.context-menu-item:hover {
  background: var(--accent);
  color: var(--text-white);
}

.context-menu-item.danger {
  color: var(--error);
}

.context-menu-item.danger:hover {
  background: var(--danger);
  color: var(--text-white);
}

/* ── Settings modal ── */

.settings-avatar-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.settings-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-white);
  flex-shrink: 0;
  overflow: hidden;
}

.settings-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.settings-avatar-upload,
.settings-invite-generate {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--accent);
  color: var(--text-white);
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.settings-avatar-upload:hover,
.settings-invite-generate:hover {
  background: var(--accent-hover);
}

.settings-avatar-remove {
  font-family: inherit;
  font-size: 0.8rem;
  background: none;
  color: var(--text-secondary);
  border: none;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.settings-avatar-remove:hover {
  color: var(--error);
}

.settings-color-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-color-row input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--border-subtle);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.settings-color-row input[type="text"] {
  flex: 1;
}

.settings-color-reset {
  font-family: inherit;
  font-size: 0.8rem;
  background: none;
  color: var(--text-secondary);
  border: none;
  padding: 0.375rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-color-reset:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

/* Login toggle link */
.login-toggle {
  text-align: center;
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.login-toggle a {
  color: var(--link);
  text-decoration: none;
}

.login-toggle a:hover {
  text-decoration: underline;
}

/* Settings: Change password */
.settings-password-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.settings-password-section > label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.settings-password-section .field {
  margin-bottom: 0.5rem;
}

.settings-password-section input {
  width: 100%;
  box-sizing: border-box;
}

.settings-password-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.settings-change-pw-btn {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--accent);
  color: var(--text-white);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-change-pw-btn:hover {
  background: var(--accent-hover);
}

.settings-pw-feedback {
  font-size: 0.8rem;
}

.settings-pw-feedback.error {
  color: var(--error-dark);
}

.settings-pw-feedback.success {
  color: var(--success);
}

/* ── Reactions ── */

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  line-height: 1.4;
}

.reaction-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.reaction-btn.reacted {
  background: var(--accent-faint);
  border-color: var(--accent);
}

.reaction-count {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.reaction-btn.reacted .reaction-count {
  color: var(--accent);
}

/* Floating reaction toolbar on hover */
.reaction-toolbar {
  display: none;
  position: absolute;
  top: -14px;
  right: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 0;
  z-index: 5;
  box-shadow: 0 2px 8px var(--overlay-lighter);
}

.message:hover .reaction-toolbar {
  display: flex;
}

.reaction-toolbar-btn {
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  color: var(--text-primary);
}

.reaction-toolbar-btn:hover {
  background: var(--bg-active);
}

.reaction-toolbar-plus {
  font-size: 1rem;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-subtle);
  border-radius: 0 4px 4px 0;
}

.reaction-toolbar-plus:hover {
  color: var(--text-primary);
}

/* ── Emoji picker ── */

.emoji-picker {
  position: fixed;
  width: 320px;
  max-height: 360px;
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow-heavy);
  z-index: 70;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.emoji-picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0;
}

.emoji-tab {
  flex: 1;
  padding: 8px 0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.emoji-tab.active {
  color: var(--text-heading);
  border-bottom-color: var(--accent);
}

.emoji-tab:hover:not(.active) {
  color: var(--text-primary);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  max-height: 300px;
}

.emoji-picker-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.3rem;
  padding: 0;
}

.emoji-picker-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.emoji-picker-item:hover {
  background: var(--bg-active);
}

.emoji-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 1rem;
}

/* ── Custom emoji inline ── */

.emoji-custom-inline {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  object-fit: contain;
}

/* ── Settings: Custom Emojis ── */

.settings-emoji-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.settings-emoji-section > label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.settings-emoji-list {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.settings-emoji-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.375rem;
  border-radius: 4px;
}

.settings-emoji-item:hover {
  background: var(--bg-active);
}

.settings-emoji-item img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.settings-emoji-item span {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.settings-emoji-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.settings-emoji-delete:hover {
  color: var(--error);
}

.emoji-list-empty {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0;
}

.settings-emoji-upload-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-emoji-upload-row input[type="text"] {
  flex: 1;
}

.settings-emoji-upload-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--accent);
  color: var(--text-white);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-emoji-upload-btn:hover {
  background: var(--accent-hover);
}

/* ── Settings: Theme ── */

.settings-theme-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.settings-theme-section > label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.settings-theme-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.settings-theme-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-theme-row .theme-label {
  width: 90px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.settings-theme-row input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--border-subtle);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-theme-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.settings-theme-reset {
  font-family: inherit;
  font-size: 0.8rem;
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.375rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-theme-reset:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

/* Loading spinner */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  gap: 0.5rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Mobile responsive */
.mobile-header {
  display: none;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 0.75rem;
}

.hamburger-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.hamburger-btn:hover {
  color: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-light);
  z-index: 20;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-header {
    display: flex;
  }

  .chat-header {
    display: none;
  }

  .thread-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 15;
    border-left: none;
  }
}
