/* ==========================================================================
   Just Me & You — mobile-first styles, light / dark themes
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --surface-3: #e3e6ee;
  --text: #171a21;
  --muted: #646b7a;
  --border: #dde1ea;
  --accent: #5b5bd6;
  --accent-hover: #4a4ac4;
  --accent-soft: rgba(91, 91, 214, 0.12);
  --accent-contrast: #ffffff;
  --bubble-in: #ffffff;
  --bubble-in-text: #171a21;
  --bubble-out: #5b5bd6;
  --bubble-out-text: #ffffff;
  --success: #1f9d55;
  --warning: #d9940a;
  --danger: #d64545;
  --track: rgba(0, 0, 0, 0.1);
  --track-out: rgba(255, 255, 255, 0.3);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 18px;
  --sidebar-w: 320px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --surface-3: #2a2f3a;
    --text: #e8eaf0;
    --muted: #9aa1b1;
    --border: #2a2f3a;
    --accent: #7c7cf0;
    --accent-hover: #9191f5;
    --accent-soft: rgba(124, 124, 240, 0.16);
    --accent-contrast: #ffffff;
    --bubble-in: #1f232c;
    --bubble-in-text: #e8eaf0;
    --bubble-out: #5656c9;
    --bubble-out-text: #ffffff;
    --success: #34c174;
    --warning: #f0b429;
    --danger: #f06363;
    --track: rgba(255, 255, 255, 0.12);
    --track-out: rgba(255, 255, 255, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --surface-3: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa1b1;
  --border: #2a2f3a;
  --accent: #7c7cf0;
  --accent-hover: #9191f5;
  --accent-soft: rgba(124, 124, 240, 0.16);
  --accent-contrast: #ffffff;
  --bubble-in: #1f232c;
  --bubble-in-text: #e8eaf0;
  --bubble-out: #5656c9;
  --bubble-out-text: #ffffff;
  --success: #34c174;
  --warning: #f0b429;
  --danger: #f06363;
  --track: rgba(255, 255, 255, 0.12);
  --track-out: rgba(255, 255, 255, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

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

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font: 15px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

a {
  color: inherit;
}

code {
  font-family: var(--mono);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ buttons */

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn.small {
  width: 32px;
  height: 32px;
}

.icon-btn.danger:hover:not(:disabled) {
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--surface-2);
}

.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ------------------------------------------------------------------ status dots */

.dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.dot[data-state="online"],
.dot[data-state="connected"] {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.18);
}

.dot[data-state="connecting"] {
  background: var(--warning);
  animation: pulse 1.2s ease-in-out infinite;
}

.dot[data-state="offline"] {
  background: var(--muted);
}

.dot[data-state="error"] {
  background: var(--danger);
}

.dot.mini {
  position: absolute;
  top: 7px;
  right: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface);
  box-shadow: none;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ------------------------------------------------------------------ layout */

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.only-mobile {
  display: inline-grid;
}

/* Sidebar is an off-canvas drawer on small screens */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(88vw, var(--sidebar-w));
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(-105%);
  transition: transform 0.25s ease;
  overflow: hidden;
}

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

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}

.me-card {
  margin: 6px 12px 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.me-label,
.field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.id-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.my-id {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  user-select: all;
}

.sig-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.field {
  display: block;
}

.field input,
.connect-form input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.connect-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.connect-form {
  display: flex;
  gap: 8px;
  margin: 0 12px 8px;
}

.connect-form input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.connect-form .btn span {
  display: none;
}

.contacts-head {
  padding: 8px 16px 4px;
}

.contacts-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.contact-list {
  flex: 1;
  margin: 0;
  padding: 4px 8px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.contacts-empty {
  flex: 1;
  margin: 0;
  padding: 8px 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.contact {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  transition: background-color 0.12s;
}

.contact:hover {
  background: var(--surface-2);
}

.contact.active {
  background: var(--accent-soft);
}

.avatar {
  --hue: 240;
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: hsl(var(--hue) 55% 52%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.avatar .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  box-shadow: none;
}

.c-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.c-name,
.c-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-name {
  font-weight: 600;
}

.c-preview {
  color: var(--muted);
  font-size: 0.85rem;
}

.c-side {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.storage-info {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: right;
}

/* ------------------------------------------------------------------ chat column */

.chat {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 60px;
  padding: 8px 8px 8px 6px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-right: max(8px, env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.peer-info {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.peer-info .avatar {
  width: 38px;
  height: 38px;
  font-size: 0.82rem;
}

.chat-head.no-peer .peer-info .avatar {
  background: var(--surface-3);
  color: var(--muted);
}

.peer-text {
  min-width: 0;
}

.peer-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.peer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.peer-status span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-actions {
  display: flex;
  flex: none;
}

.chat-actions .icon-btn {
  width: 36px;
  height: 36px;
}

.thread {
  position: relative;
  flex: 1;
  padding: 12px 10px 6px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 880px;
  margin: 0 auto;
}

.messages:empty {
  display: none;
}

.empty-state {
  max-width: 460px;
  margin: 6vh auto 0;
  padding: 0 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state h1 {
  margin: 8px 0;
  color: var(--text);
  font-size: 1.3rem;
}

.empty-state ol {
  display: inline-block;
  margin: 4px 0 18px;
  padding-left: 20px;
  text-align: left;
}

.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: var(--accent-soft);
  color: var(--accent);
}

.welcome-id code {
  overflow-wrap: anywhere;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.day-sep {
  align-self: center;
  margin: 12px 0 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.thread-note {
  align-self: center;
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

/* ------------------------------------------------------------------ messages */

.msg {
  display: flex;
  animation: msg-in 0.18s ease-out;
}

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

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.bubble {
  max-width: min(82%, 560px);
  padding: 7px 11px 5px;
  border-radius: var(--radius);
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.msg.in .bubble {
  border-bottom-left-radius: 6px;
}

.msg.out .bubble {
  border-bottom-right-radius: 6px;
  background: var(--bubble-out);
  color: var(--bubble-out-text);
}

.msg.failed .bubble {
  outline: 1px solid var(--danger);
}

.content.text {
  white-space: pre-wrap;
}

.content.text a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg.type-image .bubble {
  padding: 4px 4px 5px;
}

.msg.type-image .meta {
  padding: 0 7px;
}

.img-btn {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface-3);
  overflow: hidden;
  cursor: zoom-in;
}

.img-btn img {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: 340px;
  min-width: 80px;
  min-height: 60px;
  object-fit: contain;
}

/* File download card */
.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(240px, 60vw);
  padding: 4px 0;
}

.file-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 50px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.msg.out .file-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.file-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.file-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  opacity: 0.75;
  font-size: 0.8rem;
}

.file-dl {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.msg.out .file-dl {
  background: rgba(255, 255, 255, 0.22);
}

.file-dl:hover {
  filter: brightness(1.1);
}

.file-note {
  margin-top: 4px;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
}

.msg.out .file-note {
  color: #ffd5d5;
}

/* Transfer progress */
.progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 0 2px;
}

.progress-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
}

.msg.out .progress-track {
  background: var(--track-out);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.15s linear;
}

.msg.out .progress-bar {
  background: #fff;
}

.progress-label {
  flex: none;
  min-width: 3.2em;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  text-align: right;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 2px;
  font-size: 0.7rem;
  opacity: 0.72;
  user-select: none;
}

.status {
  font-weight: 700;
  letter-spacing: -0.1em;
}

.status[data-status="delivered"] {
  opacity: 1;
}

.status[data-status="failed"] {
  color: #ffd5d5;
  letter-spacing: 0;
}

.retry-btn {
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 2px 18px 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  padding: 7px 9px;
  border-radius: 12px;
  background: var(--bubble-in);
  box-shadow: var(--shadow);
}

.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.2s infinite ease-in-out;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ------------------------------------------------------------------ composer */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 21px;
  background: var(--surface-2);
  line-height: 1.35;
  outline: none;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer .icon-btn {
  width: 42px;
  height: 42px;
}

.send-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  transition: background-color 0.15s, transform 0.1s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

/* ------------------------------------------------------------------ overlays */

.drop-overlay {
  position: fixed;
  inset: 10px;
  z-index: 60;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 22px;
  background: rgba(91, 91, 214, 0.14);
  backdrop-filter: blur(2px);
  color: var(--accent);
  pointer-events: none;
}

.drop-overlay.disabled {
  border-color: var(--muted);
  background: rgba(100, 107, 122, 0.14);
  color: var(--muted);
}

.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 28px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 1.05rem;
  font-weight: 700;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox img {
  max-width: 100%;
  max-height: calc(100% - 70px);
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-bar {
  display: flex;
  gap: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  width: min(380px, 100%);
  padding: 22px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.modal-card p {
  margin: 0 0 16px;
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 90;
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #22262f;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}

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

.toast.error {
  background: var(--danger);
}

.noscript {
  position: fixed;
  inset: auto 0 0;
  margin: 0;
  padding: 14px;
  background: var(--danger);
  color: #fff;
  text-align: center;
}

.fatal {
  max-width: 520px;
  margin: 12vh auto;
  padding: 0 20px;
  text-align: center;
}

/* ------------------------------------------------------------------ larger screens */

@media (min-width: 480px) {
  .connect-form .btn span {
    display: inline;
  }

  .thread {
    padding: 16px 18px 8px;
  }

  .chat-actions .icon-btn {
    width: 40px;
    height: 40px;
  }
}

@media (min-width: 768px) {
  .only-mobile {
    display: none !important;
  }

  .sidebar {
    position: relative;
    z-index: auto;
    width: var(--sidebar-w);
    flex: none;
    box-shadow: none;
    transform: none;
    transition: none;
  }

  .backdrop {
    display: none;
  }

  .chat-head {
    padding-left: 16px;
  }

  .bubble {
    max-width: min(70%, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------ message requests / blocking */
.tag {
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
}

.tag.blocked {
  background: var(--surface-2);
  color: var(--danger);
}

.icon-btn[aria-pressed="true"] {
  color: var(--danger);
}

.request-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  max-width: 880px;
  width: calc(100% - 24px);
  margin: 0 auto 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.request-bar p {
  flex: 1 1 260px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.request-actions {
  display: flex;
  gap: 8px;
}

/* ------------------------------------------------------------------ access code */
.access-form {
  display: grid;
  gap: 12px;
}

.access-form p {
  margin: 0;
}

.access-form .modal-sub {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.access-form input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
}

.access-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.access-error {
  color: var(--danger);
  font-size: 0.85rem;
}
