@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;600;700&family=Roboto+Mono:wght@400;500&family=Playfair+Display:ital,wght@1,500&display=swap');

:root {
  --bg:       #080808;
  --surface:  #111111;
  --surface2: #171717;
  --red:      #D71920;
  --red-l:    #F02A32;
  --text:     #EDEDED;
  --muted:    #929292;
  --border:   #292929;
  --green:    #B7D7C0;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* ── App shell ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: opacity .2s, transform .2s;
  background: radial-gradient(ellipse at top, #1b090a 0%, var(--bg) 50%);
}
.screen.hidden { opacity: 0; pointer-events: none; transform: translateX(20px); }

/* ── Header ── */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.app-header .brand {
  font-family: 'Oswald', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: white;
  line-height: 1;
}
.app-header .brand span { color: var(--red); }
.app-header .contact-name {
  font-family: 'Oswald', sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: white;
  flex: 1;
}
.app-header .status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.app-header .status-dot.online { background: var(--green); }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; line-height: 1;
  font-size: 18px;
}
.btn-icon:hover { color: var(--red-l); }

/* ── Auth screen ── */
.auth-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  gap: 32px;
}
.auth-logo {
  text-align: center;
}
.auth-logo h1 {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(44px, 12vw, 64px);
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: white;
  line-height: 1;
}
.auth-logo h1 span { color: var(--red); }
.auth-logo p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.auth-card {
  width: 100%;
  max-width: 340px;
  padding: 28px;
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  background: linear-gradient(145deg, var(--surface2), #0e0e0e);
}
.auth-card label {
  display: block;
  color: #c5c5c5;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 7px;
}
.auth-card input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #383838;
  border-radius: 0;
  outline: none;
  background: #090909;
  color: white;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  caret-color: var(--red);
}
.auth-card input:focus { border-color: var(--red); }

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 11px 18px;
  border: none;
  cursor: pointer;
  font-family: 'Oswald', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background .15s, color .15s;
}
.btn-primary { background: var(--red); color: white; margin-top: 14px; }
.btn-primary:hover { background: var(--red-l); }
.btn-primary:disabled { background: #3a0a0c; color: var(--muted); cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  margin-top: 10px;
}
.btn-secondary:hover { border-color: var(--red); color: var(--text); }

/* ── Link / pairing screen ── */
.link-body {
  flex: 1;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.section-label {
  display: block;
  color: var(--red-l);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.card {
  padding: 22px;
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  background: linear-gradient(145deg, var(--surface2), #0e0e0e);
}
.card h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: white;
  margin-bottom: 14px;
}
.qr-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: white;
  width: fit-content;
  margin: 0 auto 14px;
}
#qr-canvas { display: block; }
.share-link-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.share-link-input {
  flex: 1;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #383838;
  background: #090909;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-copy {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Oswald', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-copy:hover { border-color: var(--red); color: var(--text); }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.paste-area {
  width: 100%;
  min-height: 72px;
  padding: 10px 13px;
  border: 1px solid #383838;
  background: #090909;
  color: white;
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
  resize: none;
  outline: none;
  caret-color: var(--red);
}
.paste-area:focus { border-color: var(--red); }
.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}
.info-row .dot { color: var(--red); }

/* ── Chat screen ── */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
.messages-wrap::-webkit-scrollbar { width: 3px; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--border); }

.msg {
  max-width: 76%;
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}
.msg.sent {
  align-self: flex-end;
  background: #2a0507;
  border: 1px solid #4a0d10;
  border-left: 2px solid var(--red);
  color: var(--text);
}
.msg.recv {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.msg .msg-ts {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1px;
  text-align: right;
}
.msg.sent .msg-ts::after { content: ' ✓'; color: var(--green); }

.day-divider {
  align-self: center;
  padding: 4px 12px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 1px solid var(--border);
  margin: 6px 0;
}

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 15px;
  text-align: center;
  padding: 40px;
}
.empty-chat small {
  font-family: 'Roboto Mono', monospace;
  font-style: normal;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Input bar ── */
.input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
#msg-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 13px;
  border: 1px solid #383838;
  background: #090909;
  color: white;
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  resize: none;
  outline: none;
  line-height: 1.5;
  caret-color: var(--red);
  overflow-y: auto;
}
#msg-input:focus { border-color: var(--red); }
#msg-input:disabled { opacity: .4; cursor: not-allowed; }
#btn-send {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border: none;
  background: var(--red);
  color: white;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
#btn-send:hover { background: var(--red-l); }
#btn-send:disabled { background: #3a0a0c; cursor: not-allowed; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 9px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--red);
  color: var(--text);
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scanner overlay ── */
#scanner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 100;
}
#scanner-overlay.hidden { display: none; }
#scanner-video {
  width: min(320px, 90vw);
  height: min(320px, 90vw);
  object-fit: cover;
  border: 2px solid var(--red);
}
.scanner-hint {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
}

/* ── Auth actions ── */
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

/* ── Invite code display ── */
.invite-code-box {
  padding: 14px 16px;
  background: #090909;
  border: 1px solid var(--border);
  border-left: 2px solid var(--red);
  text-align: center;
}
.invite-code-box code {
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  color: var(--text);
  letter-spacing: 2px;
  word-break: break-all;
}

/* ── Overlay (ajustes) ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.overlay.hidden { display: none; }
.overlay-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 2px solid var(--red);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: 'Oswald', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: white;
}
.overlay-body {
  padding: 20px 18px;
  overflow-y: auto;
}

/* ── Users bar ── */
.users-bar {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.users-bar::-webkit-scrollbar { display: none; }
.user-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Oswald', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: default;
  transition: border-color .15s;
}
.user-chip.online {
  border-color: var(--green);
  color: var(--green);
}

/* ── Sender name ── */
.msg-sender {
  display: block;
  color: var(--red-l);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

/* ── File messages ── */
.file-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}
.file-msg .file-icon { font-size: 20px; flex-shrink: 0; }
.file-msg .file-info { flex: 1; min-width: 0; }
.file-msg .file-name {
  display: block;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-msg .file-size {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1px;
}
.btn-dl {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Oswald', sans-serif;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.btn-dl:hover { border-color: var(--red); color: var(--text); }

.img-msg { flex-direction: column; align-items: flex-start; }
.img-preview {
  width: 100%;
  max-width: 220px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  margin-bottom: 6px;
}
.img-thumb {
  max-width: 220px;
  max-height: 200px;
  object-fit: contain;
  display: block;
}

/* ── File preview bar ── */
.file-preview-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.file-preview-bar.hidden { display: none; }
.file-preview-name { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-size { color: var(--muted); flex-shrink: 0; }

/* ── Responsive ── */
@media (min-width: 480px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  body {
    display: flex;
    justify-content: center;
    background: #040404;
  }
}
