/* ChatHive — App (create/chat) CSS */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  height: 100dvh
}

:root {
  --amber: #f59e0b;
  --amber-d: #d97706;
  --amber-l: #fef3c7;
  --amber-m: #fde68a;
  --bg: #fafafa;
  --surface: #fff;
  --surface2: #f5f5f5;
  --border: #e5e7eb;
  --border2: #d1d5db;
  --text: #111827;
  --text2: #374151;
  --text3: #6b7280;
  --muted: #9ca3af;
  --success: #10b981;
  --danger: #ef4444;
  --info: #3b82f6;
  --bubble-me: #f59e0b;
  --bubble-me-t: #000;
  --bubble-you: #fff;
  --bubble-you-t: #111827;
  --chat-bg: #f0f2f5;
  --sh-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --sh: 0 2px 8px rgba(0, 0, 0, .1);
  --sh-md: 0 4px 16px rgba(0, 0, 0, .12);
  --sh-lg: 0 8px 32px rgba(0, 0, 0, .15);
  --r: 16px;
  --r-sm: 10px;
  --r-xs: 7px;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2d2d2d;
  --border2: #3d3d3d;
  --text: #f9fafb;
  --text2: #e5e7eb;
  --text3: #9ca3af;
  --muted: #6b7280;
  --bubble-you: #262626;
  --bubble-you-t: #f9fafb;
  --chat-bg: #111;
  --sh-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --sh: 0 2px 8px rgba(0, 0, 0, .35);
  --sh-md: 0 4px 16px rgba(0, 0, 0, .4);
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px
}

::-webkit-scrollbar-track {
  background: transparent
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px
}

/* ── Toast ── */
#toastContainer {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
  max-width: 300px
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--sh-md);
  pointer-events: all;
  animation: toastIn .22s ease;
  background: #111;
  color: #fff
}

.toast.out {
  animation: toastOut .22s ease forwards
}

.toast-success {
  border-left: 3px solid var(--success)
}

.toast-error {
  border-left: 3px solid var(--danger)
}

.toast-info {
  border-left: 3px solid var(--info)
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(16px)
  }

  to {
    opacity: 1;
    transform: translateX(0)
  }
}

@keyframes toastOut {
  from {
    opacity: 1
  }

  to {
    opacity: 0;
    transform: translateX(16px)
  }
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(0, 0, 0, .18);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin .65s linear infinite
}

[data-theme="dark"] .spinner {
  border-color: rgba(255, 255, 255, .18);
  border-top-color: #fff
}

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

/* ══════════════════════════════════════════
   VIEW SYSTEM
   All views are full-page. Only one shown at a time via display toggle.
══════════════════════════════════════════ */
.view-create,
.view-share,
.view-chat {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: viewIn .2s ease forwards;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* ══════════════════════════════════════════
   VIEW 1: CREATE PAGE
══════════════════════════════════════════ */
.cp-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.cp-back {
  width: 36px;
  height: 36px;
  border-radius: var(--r-xs);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text2);
  flex-shrink: 0;
  transition: all .15s;
}

.cp-back:hover {
  border-color: var(--amber);
  color: var(--amber-d)
}

.cp-brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  flex: 1
}

.cp-brand span {
  color: var(--amber)
}

.cp-theme {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: all .18s;
  flex-shrink: 0
}

.cp-theme:hover {
  background: var(--amber-l);
  border-color: var(--amber);
  color: var(--amber-d)
}

.cp-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 40px
}

.cp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 20px
}

/* Tabs */
.cp-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: var(--r-sm);
  padding: 4px;
  gap: 3px;
  margin-bottom: 20px
}

.cp-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .18s
}

.cp-tab.active {
  background: var(--amber);
  color: #000;
  box-shadow: 0 2px 7px rgba(245, 158, 11, .3)
}

.cp-hint {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 16px;
  line-height: 1.5
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: var(--r-xs);
  padding: 3px;
  gap: 3px
}

.mode-tab {
  flex: 1;
  padding: 9px 8px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all .16s
}

.mode-tab.active {
  background: var(--amber);
  color: #000;
  box-shadow: 0 1px 5px rgba(245, 158, 11, .3)
}

/* Size chips */
.sz-chips {
  display: flex;
  gap: 8px
}

.sz-chip {
  flex: 1;
  padding: 9px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  transition: all .14s;
  text-align: center
}

.sz-chip.active {
  background: var(--amber-l);
  border-color: var(--amber);
  color: var(--amber-d)
}

/* Fields */
.field-grp {
  margin-bottom: 14px
}

.field-lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px
}

.opt {
  font-weight: 400;
  color: var(--muted)
}

.field-inp {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border .18s, box-shadow .18s
}

.field-inp:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .12)
}

.field-inp::placeholder {
  color: var(--muted)
}

.code-inp {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 5px;
  text-align: center
}

.code-inp::placeholder {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 2px
}

/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--amber);
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #000;
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 2px 10px rgba(245, 158, 11, .3);
  margin-top: 4px
}

.btn-primary:hover {
  background: var(--amber-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(245, 158, 11, .4)
}

.btn-primary:active {
  transform: scale(.98)
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all .18s
}

.btn-secondary:hover {
  border-color: var(--amber);
  color: var(--amber-d);
  background: var(--amber-l)
}

.or-sep {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 13px 0 10px
}

/* ══════════════════════════════════════════
   VIEW 2: SHARE PAGE
══════════════════════════════════════════ */
.view-share {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch
}

.share-page {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px 40px
}

.share-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  width: 100%;
  max-width: 460px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px
}

.share-head {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px
}

.share-ok-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(16, 185, 129, .08);
  border: 1.5px solid rgba(16, 185, 129, .22);
  display: flex;
  align-items: center;
  justify-content: center
}

.share-head h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text)
}

.share-head p {
  font-size: 13px;
  color: var(--text3)
}

.ib {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 13px 14px
}

.ib-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 8px
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px
}

.copy-txt {
  font-size: 12px;
  color: var(--amber-d);
  word-break: break-all;
  flex: 1;
  font-weight: 600;
  line-height: 1.4
}

.copy-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  background: var(--amber);
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #000;
  cursor: pointer;
  transition: all .14s;
  white-space: nowrap
}

.copy-btn:hover {
  background: var(--amber-d)
}

.copy-btn.copied {
  background: var(--success);
  color: #fff
}

.code-display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px
}

.big-code {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--amber-d);
  flex: 1
}

.copy-code-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--amber-l);
  border: 1.5px solid var(--amber-m);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--amber-d);
  flex-shrink: 0;
  transition: all .14s
}

.copy-code-btn:hover {
  background: var(--amber);
  color: #000
}

.copy-code-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: #fff
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0
}

.qr-img {
  border-radius: 10px;
  border: 4px solid var(--surface);
  box-shadow: var(--sh)
}

.share-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all .14s
}

.share-btn:hover {
  border-color: var(--amber);
  color: var(--amber-d);
  background: var(--amber-l)
}

.back-link-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  width: 100%;
  text-align: center;
  transition: color .14s
}

.back-link-btn:hover {
  color: var(--text2)
}

/* ══════════════════════════════════════════
   VIEW 3: CHAT — FULL DESKTOP LAYOUT
   On mobile: full viewport
   On desktop: centered card with background
══════════════════════════════════════════ */
.view-chat {
  background: var(--bg);
  /* On desktop, center the chat card */
}

/* The actual chat shell */
.chat-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--chat-bg);
  overflow: hidden;
}

/* Chat Header */
.chat-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 58px;
  box-shadow: var(--sh-sm);
  z-index: 10;
}

.chat-back {
  width: 34px;
  height: 34px;
  border-radius: var(--r-xs);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  flex-shrink: 0;
  transition: all .14s;
}

.chat-back:hover {
  border-color: var(--amber);
  color: var(--amber-d)
}

.chat-room-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0
}

.chat-av {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0
}

.chat-rname {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.chat-rstatus {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px
}

.chat-rstatus.live {
  color: var(--success)
}

.chat-hdr-r {
  display: flex;
  gap: 5px;
  flex-shrink: 0
}

.chat-ico-btn {
  width: 33px;
  height: 33px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: all .14s;
}

.chat-ico-btn:hover {
  border-color: var(--amber);
  color: var(--amber-d)
}

/* Chat body */
.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative
}

.msgs-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scroll-behavior: smooth;
  min-height: 0;
  overscroll-behavior: contain
}

.msgs-area::-webkit-scrollbar {
  width: 3px
}

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 28px;
  min-height: 200px
}

.empty-icon {
  opacity: .2
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text2)
}

.empty-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 220px
}

/* System messages */
.sys-msg {
  align-self: center;
  font-size: 11px;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 13px;
  font-weight: 500;
  max-width: 90%;
  text-align: center
}

/* Message rows */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  animation: msgIn .17s ease
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(4px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.msg-row.me {
  flex-direction: row-reverse
}

.msg-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #000;
  flex-shrink: 0;
  align-self: flex-end
}

.msg-body {
  display: flex;
  flex-direction: column;
  max-width: 74%
}

.msg-row.me .msg-body {
  align-items: flex-end
}

.msg-nick {
  font-size: 10px;
  font-weight: 600;
  color: var(--amber-d);
  margin-bottom: 3px;
  padding: 0 3px
}

.bubble {
  padding: 9px 13px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  cursor: pointer;
  position: relative
}

.me .bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-t);
  border-bottom-right-radius: 3px
}

.them .bubble {
  background: var(--bubble-you);
  color: var(--bubble-you-t);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm)
}

.bubble.deleted {
  opacity: .5;
  font-style: italic;
  font-size: 13px
}

.edited-tag {
  font-size: 9px;
  opacity: .55;
  margin-left: 4px
}

.reply-preview {
  background: rgba(0, 0, 0, .08);
  border-left: 3px solid rgba(0, 0, 0, .25);
  border-radius: 5px;
  padding: 4px 7px;
  margin-bottom: 5px;
  font-size: 11px;
  opacity: .85
}

.them .reply-preview {
  background: var(--amber-l);
  border-left-color: var(--amber)
}

.rp-from {
  font-weight: 700;
  margin-bottom: 1px;
  font-size: 10px
}

.msg-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  padding: 0 2px
}

.msg-row.me .msg-footer {
  flex-direction: row-reverse
}

.msg-time {
  font-size: 10px;
  color: var(--muted)
}

.msg-tick {
  font-size: 10px;
  color: var(--muted)
}

.msg-tick.sent {
  color: var(--amber)
}

/* Reactions */
.reactions {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 3px
}

.rx-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all .14s
}

.rx-chip.mine {
  background: var(--amber-l);
  border-color: var(--amber)
}

.rx-count {
  font-size: 10px;
  color: var(--text3)
}

/* File bubbles */
.file-bbl {
  padding: 9px 11px;
  border-radius: 13px;
  max-width: 220px
}

.me .file-bbl {
  background: var(--bubble-me);
  border-bottom-right-radius: 3px
}

.them .file-bbl {
  background: var(--bubble-you);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
  box-shadow: var(--sh-sm)
}

.fb-row {
  display: flex;
  align-items: center;
  gap: 8px
}

.fb-ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0
}

.me .fb-ico {
  background: rgba(0, 0, 0, .12)
}

.them .fb-ico {
  background: var(--amber-l)
}

.fb-name {
  font-size: 12px;
  font-weight: 700;
  word-break: break-word
}

.me .fb-name {
  color: #000
}

.them .fb-name {
  color: var(--text)
}

.fb-size {
  font-size: 10px;
  margin-top: 1px
}

.me .fb-size {
  color: rgba(0, 0, 0, .6)
}

.them .fb-size {
  color: var(--muted)
}

.fb-dl {
  width: 100%;
  margin-top: 7px;
  padding: 6px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
  transition: all .14s
}

.me .fb-dl {
  background: rgba(0, 0, 0, .12);
  border: 1px solid rgba(0, 0, 0, .15);
  color: #000
}

.me .fb-dl:hover {
  background: rgba(0, 0, 0, .2)
}

.them .fb-dl {
  background: var(--amber-l);
  border: 1px solid var(--amber-m);
  color: var(--amber-d)
}

.them .fb-dl:hover {
  background: var(--amber);
  color: #000
}

.img-bbl {
  border-radius: 13px;
  overflow: hidden;
  max-width: 220px;
  cursor: pointer
}

.me .img-bbl {
  border-bottom-right-radius: 3px
}

.them .img-bbl {
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border)
}

.img-bbl img {
  width: 100%;
  display: block;
  max-height: 200px;
  object-fit: cover
}

/* Voice bubble */
.voice-bbl {
  padding: 9px 12px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 175px
}

.me .voice-bbl {
  background: var(--bubble-me);
  border-bottom-right-radius: 3px
}

.them .voice-bbl {
  background: var(--bubble-you);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px
}

.v-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition: transform .14s
}

.me .v-play {
  background: rgba(0, 0, 0, .12);
  color: #000
}

.them .v-play {
  background: var(--amber);
  color: #000
}

.v-play:hover {
  transform: scale(1.1)
}

.v-bars {
  flex: 1;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 2px
}

.v-bar {
  width: 3px;
  border-radius: 2px
}

.me .v-bar {
  background: rgba(0, 0, 0, .35)
}

.them .v-bar {
  background: var(--amber)
}

.v-dur {
  font-size: 11px;
  font-weight: 600
}

.me .v-dur {
  color: rgba(0, 0, 0, .7)
}

.them .v-dur {
  color: var(--muted)
}

/* Typing indicator */
.typing-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  min-height: 26px;
  flex-shrink: 0
}

.typing-text {
  font-size: 12px;
  color: var(--muted);
  font-style: italic
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: td 1.2s infinite
}

.typing-dots span:nth-child(2) {
  animation-delay: .2s
}

.typing-dots span:nth-child(3) {
  animation-delay: .4s
}

@keyframes td {

  0%,
  60%,
  100% {
    transform: scale(1);
    opacity: .5
  }

  30% {
    transform: scale(1.4);
    opacity: 1
  }
}

/* Context menu */
.ctx-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--sh-lg);
  z-index: 500;
  min-width: 148px;
  display: none
}

.ctx-menu.show {
  display: block
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  transition: background .12s
}

.ctx-item:hover {
  background: var(--amber-l);
  color: var(--amber-d)
}

.ctx-item.danger:hover {
  background: #fef2f2;
  color: var(--danger)
}

/* React picker */
.react-picker {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 11px;
  box-shadow: var(--sh-lg);
  z-index: 501;
  display: none;
  gap: 4px
}

.react-picker.show {
  display: flex
}

.rp-btn {
  font-size: 22px;
  cursor: pointer;
  padding: 3px;
  border-radius: 7px;
  border: none;
  background: none;
  line-height: 1;
  transition: transform .14s
}

.rp-btn:hover {
  transform: scale(1.3)
}

/* Reply bar */
.reply-bar {
  padding: 7px 12px;
  background: var(--amber-l);
  border-top: 2px solid var(--amber);
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0
}

.reply-bar.show {
  display: flex
}

.rb-body {
  flex: 1;
  font-size: 12px
}

.rb-from {
  font-weight: 700;
  color: var(--amber-d);
  margin-bottom: 1px;
  font-size: 11px
}

.rb-text {
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px
}

.rb-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 2px;
  line-height: 1
}

.rb-close:hover {
  color: var(--danger)
}

/* File preview */
.file-prev-bar {
  padding: 7px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: none;
  flex-shrink: 0
}

.file-prev-bar.show {
  display: block
}

.fp-inner {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--amber-l);
  border: 1.5px solid var(--amber-m);
  border-radius: 9px;
  padding: 7px 10px
}

.fp-name {
  font-size: 13px;
  color: var(--amber-d);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600
}

.fp-sz {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap
}

.fp-x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  padding: 0 2px;
  line-height: 1
}

.fp-x:hover {
  color: var(--danger)
}

/* Input bar */
.input-bar {
  padding: 8px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 5px 6px 5px 12px;
  transition: border .18s;
  position: relative
}

.input-row:focus-within {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .1)
}

.msg-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  resize: none;
  max-height: 100px;
  line-height: 1.45;
  padding: 4px 0;
  min-height: 22px
}

.msg-textarea::placeholder {
  color: var(--muted)
}

.msg-textarea:disabled {
  opacity: .4;
  cursor: not-allowed
}

.ib-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all .14s;
  flex-shrink: 0
}

.ib-btn:hover {
  color: var(--amber-d)
}

.rec-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all .14s;
  flex-shrink: 0
}

.rec-btn:hover {
  border-color: var(--amber);
  color: var(--amber-d)
}

.rec-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: recP 1s infinite
}

@keyframes recP {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, .4)
  }

  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0)
  }
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--amber);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #000;
  transition: all .18s;
  flex-shrink: 0
}

.send-btn:hover {
  background: var(--amber-d);
  transform: scale(1.06)
}

.send-btn:active {
  transform: scale(.93)
}

.send-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
  transform: none
}

/* Emoji picker */
.emoji-picker {
  position: absolute;
  bottom: 60px;
  left: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--sh-lg);
  z-index: 50;
  display: none;
  max-height: 175px;
  overflow-y: auto
}

.emoji-picker.show {
  display: block
}

.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px
}

.ep-btn {
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 7px;
  border: none;
  background: none;
  line-height: 1
}

.ep-btn:hover {
  transform: scale(1.25)
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: -265px;
  width: 255px;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right .24s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-lg)
}

.sidebar.open {
  right: 0
}

.sb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .3);
  z-index: 199;
  display: none
}

.sb-overlay.show {
  display: block
}

.sb-hdr {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 56px
}

.sb-sec {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border)
}

.sb-sec.grow {
  flex: 1;
  overflow-y: auto
}

.sb-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 9px
}

.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text2)
}

.member-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #000;
  flex-shrink: 0
}

.member-you {
  font-size: 10px;
  color: var(--success);
  font-weight: 700;
  margin-left: auto
}

.sb-file {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 5px
}

.sbf-ico {
  font-size: 14px
}

.sbf-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.sbf-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px
}

.sbf-dl {
  background: none;
  border: none;
  color: var(--amber-d);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px
}

.no-items {
  font-size: 12px;
  color: var(--muted)
}

.sb-foot {
  padding: 12px 13px;
  flex-shrink: 0
}

.end-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  background: #fff0f0;
  border: 1.5px solid rgba(239, 68, 68, .22);
  border-radius: 9px;
  color: var(--danger);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s
}

[data-theme="dark"] .end-btn {
  background: rgba(239, 68, 68, .08)
}

.end-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger)
}

/* Edit bar */
.edit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 2px solid var(--amber);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: none;
  z-index: 100;
  gap: 7px;
  align-items: center
}

.edit-bar.show {
  display: flex
}

.edit-inp {
  flex: 1;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit
}

.edit-inp:focus {
  border-color: var(--amber)
}

.edit-save {
  padding: 8px 14px;
  background: var(--amber);
  border: none;
  border-radius: 8px;
  color: #000;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer
}

.edit-cancel {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer
}

/* ══════════════════════════════════════════
   DESKTOP RESPONSIVE — FULL SCREEN CHAT
══════════════════════════════════════════ */
@media(min-width:768px) {

  /* Create page: wider card */
  .cp-card {
    padding: 28px 28px 36px
  }

  /* Share page: wider card */
  .share-card {
    padding: 28px 24px
  }

  /* Chat: still full-size */
  .chat-shell {
    max-width: none
  }
}

@media(min-width:1024px) {

  /* ── DESKTOP CHAT — truly full screen, edge to edge ── */
  .view-chat {
    display: flex;
    background: var(--chat-bg);
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .chat-shell {
    max-width: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: hidden;
  }

  /* Wider message bubbles on desktop */
  .msg-body {
    max-width: 60%
  }

  /* ── DESKTOP CREATE — centered card ── */
  .view-create {
    background: var(--bg);
    justify-content: flex-start;
  }

  .cp-scroll {
    display: flex;
    justify-content: center
  }

  .cp-card {
    max-width: 520px;
    margin-top: 0
  }

  /* ── DESKTOP SHARE ── */
  .share-page {
    padding-top: 40px
  }

  .share-card {
    max-width: 520px
  }
}

@media(min-width:1280px) {

  /* Still fully full-screen — no max-width cap */
  .view-chat {
    padding: 0
  }

  .chat-shell {
    max-width: none;
    height: 100%
  }

  /* Comfortable bubble widths on ultra-wide */
  .msg-body {
    max-width: 50%
  }
}

/* Mobile small */
@media(max-width:380px) {
  .bubble {
    font-size: 13px
  }

  .msg-body {
    max-width: 82%
  }

  .cp-card {
    padding: 16px 14px 28px
  }

  .big-code {
    font-size: 22px;
    letter-spacing: 4px
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal
}

::view-transition-old(root) {
  z-index: 1
}

::view-transition-new(root) {
  z-index: 2
}
