/* ──────────────────────────────────────────────
   Dead Drop – Dark minimal responsive theme
   ────────────────────────────────────────────── */

:root {
  --bg:       #0a0a0f;
  --surface:  #111118;
  --border:   #222230;
  --text:     #d0d0d8;
  --dim:      #666680;
  --accent:   #00e87b;
  --danger:   #ff4455;
  --mine:     #161628;
  --theirs:   #0f1f2e;
  --radius:   8px;
  --font:     'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
}

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

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  height: 100vh; /* fallback */
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ── Pages (shared) ── */

.page {
  width: 100%;
  height: 100%;
}

/* ── Auth page ── */

.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: 12px;
  padding: 20px;
}

.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.auth-buttons {
  display: flex;
  gap: 8px;
}

.auth-buttons .btn {
  flex: 1;
  min-height: 46px;
}

.auth-error {
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  padding: 8px;
  background: rgba(255, 68, 85, 0.08);
  border-radius: var(--radius);
}

.auth-hint {
  color: var(--dim);
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
}

/* ── Landing ── */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: 12px;
  padding: 20px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 8px;
}

.logo {
  font-size: 56px;
  filter: drop-shadow(0 0 20px rgba(0, 232, 123, 0.3));
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.landing h1, .auth-page h1 {
  font-size: clamp(22px, 5vw, 32px);
  letter-spacing: clamp(4px, 1.5vw, 8px);
  color: var(--accent);
}

.tagline {
  color: var(--dim);
  font-size: clamp(11px, 2.5vw, 13px);
  letter-spacing: 2px;
  margin-bottom: 20px;
  text-align: center;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 300px;
}

.divider {
  color: var(--dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.join-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.join-group input { flex: 1; min-width: 0; }

/* ── Buttons & inputs ── */

.btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover  { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(0.97); }

.btn.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

.btn.primary:hover { background: #00ff88; }

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  min-height: 34px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

input[type="text"],
input[type="password"],
select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px; /* ≥16px prevents iOS zoom on focus */
  outline: none;
  transition: border-color 0.2s;
  min-height: 44px;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
}

select { cursor: pointer; width: auto; }

/* ── Chat layout ── */

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 2px;
  white-space: nowrap;
}

.room-info {
  font-size: 12px;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.room-info code {
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 2px;
}

.status {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status.waiting      { color: #ffaa00; }
.status.connecting   { color: #ffaa00; }
.status.connected    { color: #55aaff; }
.status.encrypted    { color: var(--accent); background: rgba(0, 232, 123, 0.1); }
.status.disconnected { color: var(--danger); }

/* ── Messages ── */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  animation: fadeIn 0.2s ease-out;
  word-break: break-word;
}

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

.msg.mine {
  align-self: flex-end;
  background: var(--mine);
  border: 1px solid var(--border);
}

.msg.theirs {
  align-self: flex-start;
  background: var(--theirs);
  border: 1px solid var(--border);
}

.msg.burn { border-color: rgba(255, 68, 85, 0.3); }

.msg.system {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 12px;
  max-width: 90%;
  text-align: center;
}

.msg-meta {
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.burn-badge {
  color: var(--danger);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.countdown {
  color: #ffaa00;
  font-variant-numeric: tabular-nums;
}

/* ── Burn animation ── */

.burning { animation: burn 0.6s ease-in forwards; }

@keyframes burn {
  0%   { opacity: 1; transform: scale(1); filter: none; }
  40%  { opacity: 0.8; transform: scale(1.02); filter: brightness(1.5) hue-rotate(-20deg); }
  100% { opacity: 0; transform: scale(0.8); filter: brightness(3) blur(4px); }
}

/* ── Chat footer ── */

.chat-footer {
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.controls {
  display: flex;
  gap: 14px;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--dim);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.toggle-label:has(input:checked) { color: var(--danger); }
.toggle-label input { accent-color: var(--danger); }

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

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

/* ── Responsive: mobile ── */

@media (max-width: 600px) {
  .logo { font-size: 48px; }
  .msg { max-width: 88%; }
  .chat-header { padding: 8px 12px; gap: 8px; }
  .chat-footer { padding: 8px 12px; }
  .messages { padding: 12px; }
  .brand { font-size: 13px; letter-spacing: 1px; }
}

/* ── Responsive: very small ── */

@media (max-width: 360px) {
  .auth-buttons { flex-direction: column; }
  .controls { gap: 10px; }
}

/* ── File messages ── */

.file-msg { max-width: 85%; }
.file-content { margin-bottom: 6px; }

.file-preview-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  display: block;
  cursor: pointer;
}

.file-preview-video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  display: block;
}

.file-preview-audio { width: 100%; min-width: 200px; }

.file-generic {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.file-icon-lg { font-size: 32px; }

.file-details {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--dim);
  flex-wrap: wrap;
}

.file-name {
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}

.file-size { white-space: nowrap; }

.file-download {
  text-decoration: none;
  font-size: 16px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.file-download:hover { opacity: 1; }

/* Attach button */

#attach-btn {
  font-size: 20px;
  padding: 6px 4px;
  min-width: 36px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

#attach-btn:hover { opacity: 1; }

/* ── File receiving progress ── */

.file-receiving {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
  padding: 4px 0;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}

.progress-text {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

/* ── Drag-and-drop overlay ── */

.messages.drag-over {
  background: rgba(0, 232, 123, 0.03);
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

@media (max-width: 600px) {
  .file-msg { max-width: 92%; }
  .file-preview-img,
  .file-preview-video { max-height: 200px; }
  .file-preview-audio { min-width: 160px; }
}

/* ── Call UI ── */

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-btn {
  font-size: 18px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.call-btn:hover { opacity: 1; }

/* Incoming call notification */

.incoming-call {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 100;
  animation: fadeIn 0.3s ease-out;
  box-shadow: 0 4px 24px rgba(0, 232, 123, 0.15);
  white-space: nowrap;
}

.incoming-call-icon {
  font-size: 24px;
  animation: ring 1s ease-in-out infinite;
}

@keyframes ring {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(15deg); }
  75% { transform: rotate(-15deg); }
}

.incoming-call-btns { display: flex; gap: 8px; }

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(255, 68, 85, 0.1); }

/* Call overlay */

.call-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.call-status-bar {
  text-align: center;
  padding: 8px;
  font-size: 13px;
  color: var(--dim);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.call-videos {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

#local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 140px;
  aspect-ratio: 4/3;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--border);
  background: #111;
  z-index: 10;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--dim);
  font-size: 64px;
  pointer-events: none;
}

.video-placeholder .placeholder-text { font-size: 14px; }

.call-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.call-ctrl {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.call-ctrl:hover { border-color: var(--accent); }

.call-ctrl.muted {
  background: rgba(255, 68, 85, 0.15);
  border-color: var(--danger);
}

.call-ctrl-end {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.call-ctrl-end:hover { background: #ff6677; border-color: #ff6677; }

@media (max-width: 600px) {
  #local-video { width: 100px; bottom: 12px; right: 12px; }
  .call-ctrl { width: 48px; height: 48px; font-size: 20px; }
  .call-controls { gap: 12px; padding: 12px; }
  .incoming-call {
    left: 12px;
    right: 12px;
    transform: none;
    justify-content: space-between;
  }
}
