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

:root {
  --bg: #0b111a;
  --shell-bg: #101923;
  --header-bg: rgba(19, 30, 41, 0.96);
  --composer-bg: rgba(19, 30, 41, 0.98);
  --bubble-in: #1b2a39;
  --bubble-out: #2d679c;
  --text: #f5f5f5;
  --text-secondary: #8ba0b4;
  --text-time: #6fb3e0;
  --text-time-out: #b9ddff;
  --accent: #6ab2f2;
  --accent-send: #6ab3f3;
  --danger: #e53935;
  --input-bg: #243445;
  --divider-bg: rgba(16, 25, 35, 0.86);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 17px;
  --radius-pill: 24px;
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-shell: 0 26px 78px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --app-max-width: 860px;
  --chat-pad-x: 10px;
  --scrollbar-size: 6px;
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
  --scrollbar-track: transparent;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.board,
textarea {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.board::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

.board::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.board::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.board::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

.board::-webkit-scrollbar-corner,
textarea::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at 20% -10%, rgba(72, 145, 220, 0.18), transparent 34%),
    radial-gradient(circle at 100% 20%, rgba(56, 97, 143, 0.14), transparent 34%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body.is-holding-touch {
  -webkit-user-select: none;
  user-select: none;
}

body.is-holding-touch * {
  -webkit-user-select: none;
  user-select: none;
}

body.is-holding-touch input,
body.is-holding-touch textarea {
  -webkit-user-select: text;
  user-select: text;
}

.app-shell {
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: var(--app-max-width);
  background: var(--shell-bg);
  position: relative;
}

.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--chat-pad-x);
  padding-top: calc(8px + var(--safe-top));
  padding-left: calc(var(--chat-pad-x) + var(--safe-left));
  padding-right: calc(var(--chat-pad-x) + var(--safe-right));
  background: var(--header-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  min-height: 56px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #79c2ff, #4b95d7);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 7px 18px rgba(74, 143, 212, 0.34);
}

.header-info {
  flex: 1;
  min-width: 0;
}

.header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  min-width: 0;
}

.header-status {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mention-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(106, 178, 242, 0.18);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.mention-pill.hidden {
  display: none;
}

.status-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.status-dot.live { background: #4caf50; box-shadow: 0 0 6px rgba(76, 175, 80, 0.5); }
.status-dot.error { background: var(--danger); }

.header-settings {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: -6px;
}

.header-settings:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.header-settings:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.94);
}

.header-settings-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.settings-panel {
  flex-shrink: 0;
  padding: 10px 14px 14px;
  padding-left: calc(14px + var(--safe-left));
  padding-right: calc(14px + var(--safe-right));
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.2);
  max-height: min(52dvh, 420px);
  overflow-y: auto;
}

.settings-panel.hidden {
  display: none;
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.settings-panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.settings-panel-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.settings-panel-close:active {
  transform: scale(0.92);
}

.settings-section {
  margin-bottom: 16px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-panel label,
.admin-panel label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-check {
  display: inline-flex !important;
  align-items: center;
  gap: 9px;
  margin: 0 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
}

.settings-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.settings-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.name-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.name-input-row input {
  flex: 1;
  min-width: 0;
}

.name-icon-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease;
}

.name-icon-btn:hover,
.admin-panel-row button:hover,
.admin-logout:hover,
.reply-preview-close:hover {
  filter: brightness(1.08);
}

.header-settings:focus-visible,
.name-icon-btn:focus-visible,
.admin-panel-row button:focus-visible,
.admin-logout:focus-visible,
.reply-preview-close:focus-visible,
.context-menu-item:focus-visible,
.context-menu-reaction:focus-visible,
.send-btn:focus-visible,
.scroll-bottom-btn:focus-visible {
  outline: 2px solid rgba(106, 178, 242, 0.72);
  outline-offset: 2px;
}

.name-icon-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.name-icon-btn--save {
  color: var(--accent);
}

.name-icon-btn--saved {
  background: rgba(106, 178, 242, 0.22);
  color: var(--accent);
}

.name-icon-btn-svg {
  width: 20px;
  height: 20px;
  display: block;
}

.name-input-row input,
.admin-panel-row input,
.admin-panel-row textarea {
  width: 100%;
  background: var(--input-bg);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 14px;
  font: inherit;
  font-size: 16px;
}

.admin-panel-row input,
.admin-panel-row textarea {
  flex: 1;
  min-width: 0;
}

.admin-panel-row textarea {
  min-height: 68px;
  resize: vertical;
}

.name-input-row input:focus,
.admin-panel-row input:focus,
.admin-panel-row textarea:focus {
  outline: 2px solid rgba(106, 178, 242, 0.55);
  outline-offset: 0;
}

.admin-panel.hidden {
  display: none;
}

.admin-panel-row {
  display: flex;
  gap: 8px;
}

.admin-panel-row--stack {
  flex-direction: column;
  margin-bottom: 14px;
}

.admin-panel-row button {
  flex-shrink: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.admin-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.admin-check {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  margin: 0 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
}

.admin-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.admin-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.admin-error.hidden {
  display: none;
}

body.admin-mode .header-status::after {
  content: " · mod";
  color: var(--accent);
}

.layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    linear-gradient(180deg, rgba(12, 19, 29, 0.88), rgba(10, 17, 26, 0.94)),
    var(--bg);
}

.board {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px var(--chat-pad-x) 16px;
  padding-left: calc(var(--chat-pad-x) + var(--safe-left));
  padding-right: calc(var(--chat-pad-x) + var(--safe-right));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 0;
  background:
    radial-gradient(circle at 18% 10%, rgba(62, 112, 160, 0.12) 0%, transparent 34%),
    radial-gradient(circle at 78% 88%, rgba(44, 82, 122, 0.12) 0%, transparent 38%),
    linear-gradient(180deg, rgba(12, 20, 30, 0.88), rgba(9, 15, 23, 0.96)),
    var(--bg);
}

.board.board-pending {
  visibility: hidden;
}

.board.board-instant .msg-row,
.msg-row--no-animate {
  animation: none;
}

.msg-row--new {
  animation: msgIn 0.18s ease;
}

.board.has-scroll-btn {
  padding-bottom: 58px;
}

.empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 28px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
}

.empty.hidden,
.date-divider.hidden,
.msg-row.hidden {
  display: none;
}

.filter-empty {
  position: absolute;
  inset: 84px 20px 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
}

.filter-empty.hidden {
  display: none;
}

.date-divider {
  display: flex;
  justify-content: center;
  padding: 14px 0 6px;
  flex-shrink: 0;
}

.date-divider span {
  background: var(--divider-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  letter-spacing: 0.02em;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: min(82%, 560px);
  margin-top: 9px;
  animation: msgIn 0.18s ease;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}

.msg-row:first-child {
  margin-top: 0;
}

.date-divider + .msg-row {
  margin-top: 4px;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row--in {
  align-self: flex-start;
}

.msg-row--out {
  align-self: flex-end;
}

.msg-row--pressing .msg,
.msg-row--menu-target .msg {
  transform: scale(0.97);
  filter: brightness(1.12);
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.msg-row--menu-target .msg {
  box-shadow:
    0 0 0 2px rgba(106, 178, 242, 0.7),
    0 4px 18px rgba(106, 178, 242, 0.28);
  filter: brightness(1.1);
}

.msg-row--grouped {
  margin-top: 3px;
}

.msg-row--grouped .msg-name {
  display: none;
}

.msg-row--grouped.msg-row--in .msg {
  border-top-left-radius: 8px;
}

.msg-row--grouped.msg-row--out .msg {
  border-top-right-radius: 8px;
}

.msg {
  position: relative;
  padding: 9px 12px 10px;
  border-radius: var(--radius-lg);
  min-width: 72px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

@media (pointer: fine) {
  .msg-row {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }

  .msg {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }
}

.msg-row--in .msg {
  background: var(--bubble-in);
  border-bottom-left-radius: 5px;
}

.msg-row--out .msg {
  background: linear-gradient(160deg, #3475ad, var(--bubble-out));
  border-bottom-right-radius: 5px;
}

.msg::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 11px;
  height: 13px;
  background: inherit;
}

.msg-row--in .msg::after {
  left: -5px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.msg-row--out .msg::after {
  right: -5px;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.msg-row--grouped .msg::after {
  display: none;
}

.msg-reply {
  display: none;
  border-left: 3px solid var(--accent);
  padding: 5px 9px 5px 8px;
  margin-bottom: 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.msg-reply:not(:empty) {
  display: block;
}

.msg-reply-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  line-height: 1.2;
}

.msg-row--out .msg-reply-name {
  color: var(--text-time-out);
}

.msg-reply-text {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-row--has-reply .msg-text {
  padding-right: 54px;
}

.msg-footer {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 4px 8px;
  justify-content: flex-end;
  margin-top: -14px;
  margin-bottom: -1px;
  min-height: 14px;
  position: relative;
  z-index: 1;
}

.msg-row--has-reactions .msg-footer {
  margin-top: 5px;
  margin-bottom: 0;
  min-height: 22px;
}

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.msg-reactions:empty {
  display: none;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  padding: 0 6px 0 4px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.1s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.msg-row--in .reaction-chip {
  background: rgba(0, 0, 0, 0.22);
}

.msg-row--out .reaction-chip {
  background: rgba(0, 0, 0, 0.16);
}

.reaction-chip:active {
  transform: scale(0.92);
}

.reaction-chip--active {
  background: rgba(106, 178, 242, 0.28);
}

.reaction-emoji {
  font-size: 14px;
  line-height: 1;
}

.reaction-count {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  min-width: 8px;
  padding-right: 2px;
}

.context-menu {
  position: fixed;
  z-index: 100;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 16px));
  border-radius: 14px;
  background: rgba(17, 27, 38, 0.98);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  padding: 6px 0;
  animation: menuPop 0.18s ease;
  transform-origin: top center;
}

@keyframes menuPop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.context-menu.hidden {
  display: none;
}

.context-menu-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.context-menu-reaction {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s ease, background 0.1s ease;
}

.context-menu-reaction:hover,
.context-menu-reaction:active {
  background: rgba(255, 255, 255, 0.1);
}

.context-menu-reaction:active {
  transform: scale(0.88);
}

.context-menu-reaction--active {
  background: rgba(106, 178, 242, 0.28);
}

.context-menu-actions {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.context-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: left;
  padding: 11px 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.context-menu-item:hover,
.context-menu-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.context-menu-item--danger {
  color: #ff6b6b;
}

.context-menu-item.hidden {
  display: none;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  margin: 0 0 6px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
}

.reply-preview.hidden {
  display: none;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
}

.reply-preview-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.reply-preview-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
}

.reply-preview-text {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
}

.admin-ban {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-ban.hidden {
  display: none;
}

.admin-logout {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  touch-action: manipulation;
}

.admin-logout:active {
  background: rgba(255, 255, 255, 0.12);
}

.msg-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.msg-row--in .msg-name {
  color: var(--accent);
}

.msg-row--out .msg-name {
  color: var(--text-time-out);
  text-align: right;
  opacity: 0.95;
}

.msg-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: -1px 0 4px;
}

.msg-row--out .msg-badges {
  justify-content: flex-end;
}

.msg-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(106, 178, 242, 0.14);
  color: var(--text-time);
  font-size: 10px;
  line-height: 1.2;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.msg-badge--pinned {
  background: rgba(229, 202, 119, 0.18);
  color: #e5ca77;
}

.msg-badge--locked {
  background: rgba(229, 57, 53, 0.16);
  color: #ff8585;
}

.msg-badge--edited {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.msg-row--pinned .msg {
  box-shadow: 0 0 0 1px rgba(229, 202, 119, 0.26), var(--shadow-soft);
}

.msg-row--admin .msg {
  background: linear-gradient(135deg, rgba(47, 90, 132, 0.86), rgba(34, 55, 75, 0.94));
}

.msg-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding-right: 52px;
}

.msg-mention {
  color: #8fd0ff;
  font-weight: 700;
}

.msg-mention--personal {
  background: rgba(106, 178, 242, 0.22);
  color: #d7efff;
  border-radius: 6px;
  padding: 0 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.msg-row--has-reactions .msg-text {
  padding-right: 0;
}

.msg-time {
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1.2;
  pointer-events: none;
  opacity: 0.75;
  white-space: nowrap;
}

.msg-row--in .msg-time {
  color: var(--text-time);
}

.msg-row--out .msg-time {
  color: var(--text-time-out);
}

.scroll-bottom-btn {
  position: absolute;
  right: calc(var(--chat-pad-x) + 4px + var(--safe-right));
  bottom: 12px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(25, 38, 51, 0.96);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

.scroll-bottom-btn:active {
  transform: scale(0.92);
}

.scroll-bottom-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.scroll-bottom-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.scroll-bottom-badge.hidden {
  display: none;
}

.composer {
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  background: var(--composer-bg);
  padding: 10px var(--chat-pad-x);
  padding-bottom: max(8px, var(--safe-bottom));
  padding-left: calc(var(--chat-pad-x) + var(--safe-left));
  padding-right: calc(var(--chat-pad-x) + var(--safe-right));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body.keyboard-open .composer {
  padding-bottom: 8px;
  box-shadow: none;
}

.composer-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-field {
  flex: 1;
  min-width: 0;
  background: var(--input-bg);
  border-radius: var(--radius-pill);
  padding: 3px 3px 3px 6px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.025);
  position: relative;
}

textarea {
  display: block;
  width: 100%;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

textarea:focus {
  outline: none;
}

textarea::placeholder {
  color: var(--text-secondary);
}

.mention-menu {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 196px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(17, 27, 38, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  overflow-y: auto;
  z-index: 60;
  isolation: isolate;
}

.mention-menu.hidden {
  display: none;
}

.mention-option {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
}

.mention-option:hover,
.mention-option:focus-visible,
.mention-option--active {
  background: rgba(106, 178, 242, 0.18);
  outline: none;
}

.mention-option-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.mention-option-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-secondary);
}

.composer-field:focus-within {
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.14),
    0 0 0 2px rgba(106, 178, 242, 0.28);
}

.send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #7bc4ff, var(--accent-send));
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 10px 24px rgba(106, 179, 243, 0.32);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.send-btn:hover { filter: brightness(1.06); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.45; cursor: wait; }

.send-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  margin-left: 2px;
}

@media (max-width: 720px) {
  .app-shell {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    height: 100%;
    height: 100dvh;
  }
}

@media (max-width: 480px) {
  :root {
    --chat-pad-x: 8px;
  }

  .header {
    min-height: 52px;
    padding: 8px var(--chat-pad-x);
    padding-top: calc(8px + var(--safe-top));
    padding-left: calc(var(--chat-pad-x) + var(--safe-left));
    padding-right: calc(var(--chat-pad-x) + var(--safe-right));
  }

  .header-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .header h1 {
    font-size: 15px;
  }

  .header-status {
    font-size: 12px;
  }

  .board {
    padding: 10px var(--chat-pad-x) 12px;
    padding-left: calc(var(--chat-pad-x) + var(--safe-left));
    padding-right: calc(var(--chat-pad-x) + var(--safe-right));
  }

  .msg-row {
    max-width: 89%;
    margin-top: 8px;
  }

  .msg-row--grouped {
    margin-top: 3px;
  }

  .msg {
    padding: 8px 10px 9px;
  }

  .msg-text {
    font-size: 16px;
    line-height: 1.42;
  }

  .reaction-chip {
    height: 21px;
    padding: 0 5px 0 3px;
  }

  .reaction-emoji {
    font-size: 13px;
  }

  .reaction-count {
    font-size: 11px;
  }

  .composer {
    padding: 8px var(--chat-pad-x);
    padding-bottom: max(6px, var(--safe-bottom));
    padding-left: calc(var(--chat-pad-x) + var(--safe-left));
    padding-right: calc(var(--chat-pad-x) + var(--safe-right));
  }

  .settings-panel {
    max-height: min(58dvh, 430px);
  }

  .send-btn,
  .scroll-bottom-btn {
    width: 42px;
    height: 42px;
  }

  .context-menu-reaction {
    width: 42px;
    height: 42px;
  }
}

@media (min-width: 721px) {
  body {
    background:
      radial-gradient(circle at 35% -12%, rgba(81, 150, 216, 0.22) 0%, transparent 42%),
      radial-gradient(circle at 72% 18%, rgba(57, 91, 132, 0.16) 0%, transparent 38%),
      linear-gradient(135deg, #08101a, #0d1621 55%, #070d14);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 16px;
  }

  .app-shell {
    height: auto;
    max-height: calc(100dvh - 32px);
    flex: 1;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-shell);
  }

  .header {
    border-radius: 16px 16px 0 0;
  }

  .app-shell {
    position: relative;
    inset: auto;
    width: auto;
    max-width: var(--app-max-width);
    height: auto;
    max-height: calc(100dvh - 32px);
    margin: 0 auto;
  }

  .board {
    padding: 14px 18px 12px;
  }

  .msg-row {
    max-width: min(76%, 560px);
  }

  .composer {
    border-radius: 0 0 16px 16px;
    padding: 10px 14px 12px;
    padding-bottom: calc(12px + var(--safe-bottom));
  }

  .composer-inner {
    gap: 10px;
  }

  .composer-field {
    padding: 3px 4px;
  }

  textarea {
    padding: 11px 16px;
  }

  .send-btn {
    width: 46px;
    height: 46px;
  }
}
