:root {
  --bg: #0c0e12;
  --surface: rgba(28, 32, 42, 0.72);
  --accent: #5b8cff;
  --accent-muted: rgba(91, 140, 255, 0.35);
  --danger: #ff5b6b;
  --text: #e8eaef;
  --muted: #8b92a5;
  --radius: 999px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  /* dvh tracks the visible viewport on iOS Safari (collapses with address bar).
     Falls back to 100% on older browsers. */
  height: 100dvh;
  font-family: "SF Pro Text", system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none; /* prevent iOS rubber-band bounce shifting layout */
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

#video-stage {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  gap: 0;
  padding: 0;
  background: var(--bg);
}

#call-stack {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#call-layout {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#remote-fullscreen {
  position: absolute;
  inset: 0;
  background: #080a0d;
}

#remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #080a0d;
}

#remote-name-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 70% 50% at 50% 45%, #1a2030 0%, #080a0d 70%);
  pointer-events: none;
}

#remote-name-overlay[hidden],
#audio-only-call[hidden] {
  display: none !important;
}

#remote-name-text {
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 600;
  color: var(--text);
  text-align: center;
  max-width: 90%;
}

#local-pip {
  position: absolute;
  top: max(72px, calc(env(safe-area-inset-top) + 56px));
  right: max(12px, env(safe-area-inset-right));
  z-index: 8;
  width: min(28vw, 200px);
  max-width: 44%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.12);
  background: #0a0c10;
}

#local-pip canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#audio-only-call {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, #151a24 0%, #080a0d 85%);
}

.audio-only-remote {
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.audio-only-you {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

#rtc-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  z-index: 20;
  position: relative;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, rgba(12, 14, 18, 0.94) 0%, rgba(12, 14, 18, 0.72) 70%, transparent 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* collapsed when no content is visible inside */
  min-height: 0;
}

#rtc-session-panel {
  flex: 1;
  min-width: 200px;
}

.session-or-divider {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 2px 0 8px;
}

.join-code-input {
  width: 100px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.12em;
  text-align: center;
}

.join-code-input::placeholder {
  color: var(--muted);
  letter-spacing: 0.08em;
}

.display-name-input {
  flex: 1;
  min-width: 140px;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.9rem;
}

.display-name-input::placeholder {
  color: var(--muted);
}

.session-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}


.btn-session {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: linear-gradient(145deg, #3d9a6a, #2d7a52);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.btn-session.secondary {
  background: var(--surface);
  font-weight: 500;
}

.btn-session:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-session:not(:disabled):hover {
  filter: brightness(1.06);
}

.rtc-status {
  font-size: 0.8rem;
  color: var(--muted);
  flex-basis: 100%;
}

@media (min-width: 520px) {
  .rtc-status {
    flex-basis: auto;
  }
}

#feed-placeholder {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.95rem;
  background: rgba(8, 10, 13, 0.82);
  backdrop-filter: blur(6px);
}

/* Lobby — pre-session start/join UI inside the placeholder */
#lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 300px;
}

.lobby-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.lobby-name-row {
  width: 100%;
}

.lobby-name-row .display-name-input {
  width: 100%;
  max-width: 100%;
  text-align: center;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-lobby-primary {
  width: 100%;
  padding: 13px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  background: linear-gradient(145deg, #3d9a6a, #2d7a52);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: filter 0.15s ease;
}

.btn-lobby-primary:hover { filter: brightness(1.08); }
.btn-lobby-primary:active { transform: scale(0.98); }

.btn-lobby-secondary {
  width: 100%;
  padding: 11px 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  background: rgba(28, 32, 42, 0.55);
  backdrop-filter: blur(8px);
  transition: background 0.15s ease;
}

.btn-lobby-secondary:hover { background: rgba(48, 54, 72, 0.75); }

.join-code-form {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

.join-code-form .join-go {
  width: auto;
  padding: 13px 20px;
  flex-shrink: 0;
}

#feed-placeholder[hidden] {
  display: none;
}

#placeholder-msg {
  margin: 0;
  max-width: 280px;
  line-height: 1.5;
  font-size: 1rem;
  color: var(--muted);
}

#placeholder-msg[hidden],
#session-waiting[hidden],
#lobby[hidden] {
  display: none;
}

/* Session-waiting panel — shown after "Start a session" */
#session-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.session-share-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.session-code-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 28px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
}

.session-code-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--text);
  user-select: all;
}

.copy-link-btn {
  width: 100%;
}

.session-status-msg {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2em;
}

.btn-lobby-text {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}

.btn-lobby-text:hover {
  color: var(--text);
}

/* ─── Network quality indicator ──────────────────────────────────── */

#net-quality {
  position: absolute;
  /* sits just below the mic meter (~42px of mic-meter content + 8px gap) */
  top: max(66px, calc(env(safe-area-inset-top) + 56px));
  left: max(16px, env(safe-area-inset-left));
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

#app.session-live #net-quality {
  opacity: 1;
  visibility: visible;
}

.net-quality-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 3px 4px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.net-quality-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.net-quality-icon {
  width: 20px;
  height: 16px;
  display: block;
}

/* Default: all bars dim */
#net-quality .bar {
  fill: rgba(255, 255, 255, 0.18);
  transition: fill 0.4s ease;
}

/* Good — all 3 bars green */
#net-quality[data-quality="good"] .bar-1,
#net-quality[data-quality="good"] .bar-2,
#net-quality[data-quality="good"] .bar-3 { fill: #4ade80; }

/* Fair — 2 bars amber, tallest dim */
#net-quality[data-quality="fair"] .bar-1,
#net-quality[data-quality="fair"] .bar-2 { fill: #fbbf24; }

/* Poor — 1 bar red, others dim */
#net-quality[data-quality="poor"] .bar-1 { fill: #f87171; }

/* Stats panel — slides in to the right of the icon */
.net-stats {
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: rgba(8, 10, 13, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.net-stats[hidden] { display: none; }

/* Colour the individual stat values to match quality */
#net-quality[data-quality="good"]  .net-stats { color: #86efac; }
#net-quality[data-quality="fair"]  .net-stats { color: #fde68a; }
#net-quality[data-quality="poor"]  .net-stats { color: #fca5a5; }

/* ─── Mic level ───────────────────────────────────────────────────── */
/* Mic level — top left, same visibility as call controls */
#mic-meter {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 22;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

#app.session-live #mic-meter {
  opacity: 1;
  visibility: visible;
}

#mic-meter-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

#mic-meter-track {
  width: 120px;
  height: 6px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

#mic-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #3d7cff, #6af0c4);
  transition: width 0.05s linear;
  box-shadow: 0 0 12px rgba(91, 140, 255, 0.45);
}

/* Bottom controls — only during an active signaling session (.session-live on #app) */
#controls {
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(12, 14, 18, 0.96) 35%);
  transition:
    opacity 0.35s ease,
    max-height 0.45s ease,
    padding 0.45s ease,
    visibility 0.35s;
}

#app.session-live #controls {
  max-height: 180px;
  opacity: 1;
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom));
  overflow: visible;
  visibility: visible;
  pointer-events: auto;
}

#app.session-setup-enter #rtc-session-panel,
#app.session-setup-enter #feed-placeholder {
  animation: sessionSetupIn 0.48s ease;
}

@keyframes sessionSetupIn {
  from {
    opacity: 0.5;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #app.session-setup-enter #rtc-session-panel,
  #app.session-setup-enter #feed-placeholder {
    animation: none;
  }

  #controls {
    transition: none;
  }
}

.btn-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-round:hover {
  transform: scale(1.05);
  background: rgba(38, 44, 58, 0.85);
}

.btn-round:active {
  transform: scale(0.98);
}

.btn-round svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#btn-mic.muted {
  background: rgba(255, 91, 107, 0.25);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 91, 107, 0.35);
  color: #ffb3ba;
}

#btn-camera.cam-on {
  background: linear-gradient(145deg, rgba(91, 140, 255, 0.4), rgba(61, 111, 217, 0.35));
  box-shadow: var(--shadow), 0 0 0 1px rgba(91, 140, 255, 0.45);
  color: #a8c4ff;
}

#btn-hangup {
  width: 64px;
  height: 64px;
  background: linear-gradient(145deg, #e04555, #c02d3c);
  color: #fff;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

#btn-hangup:hover {
  background: linear-gradient(145deg, #f05565, #d03545);
}

#btn-hangup svg {
  width: 26px;
  height: 26px;
}

#status-toast {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 40;
}

#status-toast.visible {
  opacity: 1;
}

/* ─── Chat button ─────────────────────────────────────────────────── */

#btn-chat {
  position: relative;
}

#btn-chat.chat-open {
  background: rgba(91, 140, 255, 0.22);
  box-shadow: var(--shadow), 0 0 0 1px rgba(91, 140, 255, 0.38);
  color: #a8c4ff;
}

.chat-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--bg);
}

.chat-badge[hidden] {
  display: none;
}

/* ─── Floating chat panel ─────────────────────────────────────────── */

.chat-panel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(130px, calc(env(safe-area-inset-bottom) + 120px));
  width: min(300px, calc(100vw - 32px));
  max-height: min(430px, calc(100vh - 200px));
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  z-index: 35;
  overflow: hidden;
  background: rgba(18, 22, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.09);
  /* closed state: slid off to the right + invisible */
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.22s ease;
}

.chat-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-panel[hidden] {
  display: none !important;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.chat-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.chat-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  color: var(--text);
}

.chat-close-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* Message list */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
}

.chat-msg-self {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-peer {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-name {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  padding: 0 6px;
}

.chat-msg-text {
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.87rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg-self .chat-msg-text {
  background: linear-gradient(145deg, rgba(61, 111, 217, 0.75), rgba(45, 85, 180, 0.7));
  color: #dce8ff;
  border-bottom-right-radius: 5px;
}

.chat-msg-peer .chat-msg-text {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-bottom-left-radius: 5px;
}

/* Input row */
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.chat-input-field {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 0.87rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

.chat-input-field::placeholder {
  color: var(--muted);
}

.chat-input-field:focus {
  border-color: rgba(91, 140, 255, 0.45);
}

.btn-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #3d6fd9, #2d55b4);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-chat-send:hover {
  filter: brightness(1.12);
}

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

.btn-chat-send svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-chat-send svg polygon {
  fill: currentColor;
  stroke: none;
}

/* Attachment button */
.btn-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-attach:hover {
  background: rgba(255, 255, 255, 0.13);
  color: var(--text);
}

.btn-attach:active {
  transform: scale(0.93);
}

.btn-attach svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* File message bubble — shares the same look as .chat-msg-text */
.chat-msg-file {
  padding: 10px 12px;
  border-radius: 14px;
  min-width: 160px;
}

.chat-msg-self .chat-msg-file {
  background: linear-gradient(145deg, rgba(61, 111, 217, 0.75), rgba(45, 85, 180, 0.7));
  color: #dce8ff;
  border-bottom-right-radius: 5px;
}

.chat-msg-peer .chat-msg-file {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-bottom-left-radius: 5px;
}

/* Image bubbles get zero padding so the photo fills edge-to-edge */
.chat-msg-file--image {
  padding: 0;
  overflow: hidden;
}

/* File info row: icon + name + size */
.file-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.file-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.file-size-text {
  font-size: 0.73rem;
  opacity: 0.6;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Transfer progress bar */
.file-progress {
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  margin-top: 8px;
  overflow: hidden;
}

.file-progress-fill {
  height: 100%;
  background: rgba(91, 140, 255, 0.85);
  border-radius: 3px;
  transition: width 0.12s ease;
}

/* Download link */
.file-dl-btn {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(130, 175, 255, 0.95);
  text-decoration: none;
}

.file-dl-btn:hover {
  color: #a8c8ff;
  text-decoration: underline;
}

/* Inline image preview */
.chat-img-preview {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  object-fit: contain;
  cursor: zoom-in;
}

.chat-msg-file--image .chat-img-preview {
  border-radius: 14px;
}
