/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Constryn — deep blue theme */
  --ig-bg: #ffffff;
  --ig-white: #ffffff;
  --ig-border: #dbdbdb;
  --ig-text: #0a2540;
  --ig-secondary: #5b6b7c;
  --ig-blue: #1a56db;
  --ig-link: #0a2540;
  --ig-gradient: linear-gradient(45deg, #0a2540, #123a6b, #1a56db, #2563eb, #3b82f6);
  --ig-like: #1a56db;
  --ig-hover: #f0f4fa;
  --ig-input-bg: #eef2f7;
  --ig-msg-received: #eef2f7;
  --ig-msg-system: #dce8f8;
  --ig-body-bg: #ffffff;
  --ig-toast-bg: #0a2540;
  --nav-height: 44px;
  --bottom-nav: 50px;
  --max-width: 470px;
}

/* Dark theme — deep navy */
[data-theme="dark"] {
  --ig-bg: #050d18;
  --ig-white: #050d18;
  --ig-border: #1a2a40;
  --ig-text: #e8eef6;
  --ig-secondary: #8b9bb0;
  --ig-blue: #3b82f6;
  --ig-link: #93c5fd;
  --ig-like: #3b82f6;
  --ig-hover: #0c1a2e;
  --ig-input-bg: #0c1a2e;
  --ig-msg-received: #0c1a2e;
  --ig-msg-system: #132d4a;
  --ig-body-bg: #050d18;
  --ig-toast-bg: #e8eef6;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--ig-body-bg);
  color: var(--ig-text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  transition: background 0.25s ease, color 0.25s ease;
}

/* ===== App Container (Instagram phone frame) ===== */
.app {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  background: var(--ig-white);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  box-shadow: none;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background 0.25s ease;
}

@media (min-width: 500px) {
  .app {
    box-shadow: 0 0 40px rgba(0,0,0,0.12);
  }
}

/* ===== Top Navigation ===== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--ig-white);
  border-bottom: 1px solid var(--ig-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
}

.logo {
  font-family: 'Grand Hotel', cursive;
  font-size: 29px;
  letter-spacing: 0.5px;
  color: var(--ig-text);
  background: none;
  -webkit-text-fill-color: unset;
  font-weight: 400;
}

.top-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-icons .icon-btn {
  font-size: 24px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ig-text);
  cursor: pointer;
  position: relative;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active { opacity: 0.5; }
.icon-btn:hover { opacity: 0.6; }

.badge {
  position: absolute;
  top: -2px;
  right: -6px;
  background: var(--ig-like);
  color: white;
  font-size: 10px;
  font-weight: 600;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Stories (horizontal Instagram-style) ===== */
.stories {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 14px;
  padding: 12px 12px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--ig-border);
  background: var(--ig-white);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.stories::-webkit-scrollbar { display: none; }

.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex: 0 0 auto;
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  cursor: pointer;
}

.story-item span {
  font-size: 11px;
  color: var(--ig-text);
  width: 72px;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.story-ring {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  max-width: 64px;
  max-height: 64px;
  border-radius: 50%;
  padding: 2.5px;
  background: var(--ig-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
}

.story-item.your-story .story-ring {
  background: var(--ig-border);
}

.story-avatar,
.story-ring img {
  width: 56px !important;
  height: 56px !important;
  min-width: 56px;
  min-height: 56px;
  max-width: 56px;
  max-height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid var(--ig-white);
  background: #eee;
  display: block;
}

.story-avatar.add {
  width: 56px !important;
  height: 56px !important;
  background: var(--ig-msg-received);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ig-text);
  font-size: 20px;
}

/* ===== Feed ===== */
.feed {
  padding-bottom: calc(var(--bottom-nav) + 20px);
  background: var(--ig-white);
}

.post {
  border-bottom: 1px solid var(--ig-border);
  margin-bottom: 12px;
  width: 100%;
}

.post-header {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
}

.post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
}

.post-user {
  flex: 1;
  cursor: pointer;
}

.post-user strong {
  font-size: 13.5px;
  font-weight: 600;
  display: block;
}

.post-user .skill {
  font-size: 11.5px;
  color: var(--ig-secondary);
}

.post-more {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--ig-text);
}

.post-media {
  position: relative;
  width: 100%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.post-image {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 5; /* Instagram portrait — taller, bigger on phone */
  object-fit: cover;
  display: block;
  background: var(--ig-msg-received);
  pointer-events: none;
}

/* Double-tap heart (Instagram-style) */
.dbl-like-heart {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  color: #fff;
  font-size: 90px;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.35));
}

.dbl-like-heart.pop {
  animation: igHeartPop 0.85s ease-out forwards;
}

@keyframes igHeartPop {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  30%  { transform: translate(-50%, -50%) scale(0.95); opacity: 1; }
  45%  { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
  80%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}

.post-actions {
  display: flex;
  align-items: center;
  padding: 6px 12px 0;
  gap: 14px;
}

.post-actions .icon-btn {
  font-size: 24px;
  padding: 6px 2px;
  min-width: auto;
  min-height: auto;
}

.post-actions .liked {
  color: var(--ig-like);
}

.post-actions .actions-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hire-btn {
  background: transparent;
  color: var(--ig-blue);
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: auto;
  -webkit-tap-highlight-color: transparent;
}

.hire-btn:active,
.hire-btn:hover {
  opacity: 0.7;
  background: transparent;
}

.post-likes {
  padding: 6px 14px 2px;
  font-size: 14px;
  font-weight: 600;
}

.post-caption {
  padding: 2px 14px 4px;
  font-size: 14px;
  line-height: 1.4;
}

.post-caption strong {
  font-weight: 600;
  margin-right: 4px;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 14px 2px;
}

.tag {
  background: transparent;
  color: var(--ig-link);
  font-size: 13px;
  padding: 0;
  border-radius: 0;
  font-weight: 400;
}

.post-time {
  padding: 4px 14px 14px;
  font-size: 10px;
  color: var(--ig-secondary);
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.post-hire-row {
  padding: 4px 14px 0;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: calc(var(--bottom-nav) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--ig-white);
  border-top: 1px solid var(--ig-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--ig-text);
  cursor: pointer;
  padding: 12px 16px; /* larger touch target for Android */
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
}

.nav-btn.active {
  color: var(--ig-text);
}

.nav-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid transparent;
}

.nav-btn.active .nav-avatar {
  border-color: var(--ig-text);
}

/* ===== Messages Panel ===== */
.messages-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--ig-white);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.messages-panel.open {
  transform: translateX(0);
}

.messages-header {
  height: var(--nav-height);
  border-bottom: 1px solid var(--ig-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
}

.messages-header h2 {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
}

.back-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--ig-text);
  padding: 4px;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
}

.chat-preview {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-preview:hover, .chat-preview.active {
  background: var(--ig-hover);
}

.chat-preview img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-preview-info {
  flex: 1;
  min-width: 0;
}

.chat-preview-info strong {
  font-size: 14px;
  display: block;
}

.chat-preview-info p {
  font-size: 13px;
  color: var(--ig-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-preview .time {
  font-size: 11px;
  color: var(--ig-secondary);
}

.unread-dot {
  width: 8px;
  height: 8px;
  background: var(--ig-blue);
  border-radius: 50%;
}

/* ===== Chat Window ===== */
.chat-window {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--ig-white);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.chat-window.open {
  transform: translateX(0);
}

.chat-header {
  height: var(--nav-height);
  border-bottom: 1px solid var(--ig-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
}

.chat-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-user strong {
  font-size: 14px;
  display: block;
}

.chat-user .status {
  font-size: 11px;
  color: var(--ig-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--ig-bg);
}

.message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.message.received {
  background: var(--ig-msg-received);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message.sent {
  background: var(--ig-blue);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.system {
  align-self: center;
  background: var(--ig-msg-system);
  color: var(--ig-link);
  font-size: 12.5px;
  text-align: center;
  max-width: 90%;
  border-radius: 12px;
}

.chat-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  gap: 8px;
  border-top: 1px solid var(--ig-border);
  background: var(--ig-white);
}

.chat-input-area input {
  flex: 1;
  border: 1px solid var(--ig-border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 16px;
  outline: none;
  background: var(--ig-input-bg);
  color: var(--ig-text);
}

.chat-input-area input:focus {
  border-color: #c7c7c7;
}

.send-btn {
  background: none;
  border: none;
  color: var(--ig-blue);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--ig-white);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.25s ease;
  color: var(--ig-text);
}

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

.close-modal {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--ig-secondary);
  cursor: pointer;
  z-index: 1;
}

/* Profile Modal */
.profile-modal {
  padding: 24px 20px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 16px;
}

.profile-avatar-lg {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-stats {
  display: flex;
  gap: 20px;
  text-align: center;
}

.profile-stats strong {
  display: block;
  font-size: 17px;
}

.profile-stats span {
  font-size: 12px;
  color: var(--ig-secondary);
}

.profile-info h3 {
  font-size: 16px;
  margin-bottom: 2px;
}

.skill-tag {
  color: var(--ig-blue);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.profile-info p {
  font-size: 13.5px;
  line-height: 1.4;
  margin-bottom: 4px;
}

.location {
  color: var(--ig-secondary);
  font-size: 12.5px !important;
}

.profile-actions {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.btn-primary {
  background: var(--ig-blue);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  transition: background 0.2s;
}

.btn-primary:hover { background: #0077cc; }

.btn-primary.full {
  width: 100%;
  margin-top: 8px;
}

.btn-outline {
  background: var(--ig-msg-received);
  color: var(--ig-text);
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin-top: 12px;
}

.profile-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Deal Modal */
.deal-modal {
  padding: 28px 24px;
}

.deal-modal h2 {
  font-size: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.deal-worker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--ig-hover);
  border-radius: 12px;
}

.deal-worker img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.deal-worker strong {
  display: block;
  font-size: 15px;
}

.deal-worker span {
  font-size: 12.5px;
  color: var(--ig-secondary);
}

#dealForm label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 14px;
}

#dealForm input,
#dealForm textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ig-border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
  background: var(--ig-input-bg);
  color: var(--ig-text);
}

#dealForm input:focus,
#dealForm textarea:focus {
  border-color: var(--ig-blue);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ig-toast-bg);
  color: var(--ig-white);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 400;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

[data-theme="dark"] .toast {
  color: #121212;
}

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

/* ===== Language Modal ===== */
.lang-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 350;
  display: none;
  align-items: flex-end;
  justify-content: center;
  /* never affect layout of the app behind */
  pointer-events: none;
}

.lang-modal.open {
  display: flex;
  pointer-events: auto;
}

.lang-modal-content {
  background: var(--ig-white);
  width: 100%;
  max-width: var(--max-width);
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  animation: slideUp 0.25s ease;
  color: var(--ig-text);
}

.lang-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ig-border);
}

.lang-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.lang-list {
  overflow-y: auto;
  max-height: 55vh;
  padding: 8px 0;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.lang-item:hover, .lang-item.active {
  background: var(--ig-hover);
}

.lang-item .flag {
  font-size: 22px;
  width: 32px;
  text-align: center;
}

.lang-item .lang-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.lang-item .lang-native {
  font-size: 13px;
  color: var(--ig-secondary);
}

.lang-item .check {
  color: var(--ig-blue);
  font-size: 16px;
  opacity: 0;
}

.lang-item.active .check {
  opacity: 1;
}

/* ===== Cross-platform responsive (Desktop / Tablet / Mobile) ===== */
@media (min-width: 500px) {
  body {
    padding: 24px 0;
    background: var(--ig-body-bg);
  }
  .app {
    border-radius: 16px;
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  }
  .bottom-nav {
    border-radius: 0 0 16px 16px;
  }
  .top-nav {
    border-radius: 16px 16px 0 0;
  }
  .lang-modal {
    align-items: center;
  }
  .lang-modal-content {
    border-radius: 16px;
    max-width: 360px;
  }
}

/* Large desktop – keep Instagram phone-frame feel but centered */
@media (min-width: 900px) {
  body {
    padding: 40px 0;
  }
  .app {
    box-shadow: 0 12px 50px rgba(0,0,0,0.15);
  }
}

/* Ensure forms and buttons work well with mouse + keyboard on desktop */
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover,
  .nav-btn:hover,
  .hire-btn:hover,
  .btn-primary:hover,
  .btn-outline:hover,
  .chat-preview:hover {
    cursor: pointer;
  }
}

/* RTL support for Arabic */
[dir="rtl"] .top-nav,
[dir="rtl"] .post-header,
[dir="rtl"] .post-actions,
[dir="rtl"] .chat-header,
[dir="rtl"] .messages-header,
[dir="rtl"] .chat-input-area,
[dir="rtl"] .profile-actions {
  flex-direction: row-reverse;
}
[dir="rtl"] .post-actions .hire-btn {
  margin-right: auto;
  margin-left: 0;
}
[dir="rtl"] .message.sent {
  align-self: flex-start;
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 4px;
}
[dir="rtl"] .message.received {
  align-self: flex-end;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
}


/* ===== Video posts ===== */
.post-video-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 5; /* match image posts — larger on mobile */
  background: #000;
  overflow: hidden;
}

.post-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  transition: opacity 0.2s;
}

.video-play-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.video-play-overlay i {
  font-size: 56px;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.video-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Voice notes in chat ===== */
.voice-btn {
  color: var(--ig-text);
}

.voice-btn.recording {
  color: var(--ig-like);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.voice-recording-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--ig-white);
  border-top: 1px solid var(--ig-border);
}

.voice-recording-bar.active {
  display: flex;
}

.rec-dot {
  width: 10px;
  height: 10px;
  background: var(--ig-like);
  border-radius: 50%;
  animation: pulse 1s infinite;
}

#recTimer {
  font-size: 14px;
  font-weight: 600;
  min-width: 36px;
}

.rec-hint {
  flex: 1;
  font-size: 13px;
  color: var(--ig-secondary);
}

/* Voice message bubble */
.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  max-width: 260px;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.08);
  color: var(--ig-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.message.sent .voice-play-btn {
  background: rgba(255,255,255,0.25);
  color: white;
}

.voice-waveform {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-waveform span {
  width: 3px;
  background: currentColor;
  border-radius: 2px;
  opacity: 0.6;
}

.voice-duration {
  font-size: 11px;
  opacity: 0.8;
  min-width: 28px;
}

/* ===== Call Overlay ===== */
.call-overlay {
  position: absolute;
  inset: 0;
  z-index: 250;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  color: white;
}

.call-overlay.active {
  display: flex;
}

.call-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  z-index: 0;
}

.call-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 40px 24px;
  height: 100%;
}

.call-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.2);
  margin-top: 60px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.call-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 6px;
}

#callStatus {
  font-size: 15px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.call-timer {
  font-size: 14px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  min-height: 20px;
}

.call-actions {
  display: flex;
  gap: 28px;
  margin-top: auto;
  margin-bottom: 50px;
}

.call-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 12px;
}

.call-action-btn i {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: background 0.2s;
}

.call-action-btn:active i {
  background: rgba(255,255,255,0.3);
}

.call-action-btn.muted i {
  background: var(--ig-like);
}

.call-action-btn.end-btn i {
  background: var(--ig-like);
  font-size: 20px;
}

.call-action-btn.speaker-on i {
  background: var(--ig-blue);
}

/* Video call preview */
.video-call-preview {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.video-call-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #16213e;
  font-size: 80px;
  color: rgba(255,255,255,0.3);
}

#localVideo {
  position: absolute;
  bottom: 140px;
  right: 16px;
  width: 100px;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  z-index: 2;
  background: #000;
}

/* Incoming call banner (optional) */
.incoming-call-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--ig-white);
  padding: 16px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 260;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.incoming-call-banner.active {
  display: flex;
}

/* ===== Group Video Call ===== */
.group-call-ui {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 120px;
}

.group-call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  background: rgba(0,0,0,0.4);
  color: white;
  font-size: 14px;
  z-index: 2;
}

.group-call-header #groupCallTitle {
  font-weight: 600;
  font-size: 16px;
}

.group-video-grid {
  flex: 1;
  display: grid;
  gap: 4px;
  padding: 4px;
  overflow: hidden;
  align-content: center;
}

/* Dynamic grid layouts */
.group-video-grid.grid-1 { grid-template-columns: 1fr; }
.group-video-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.group-video-grid.grid-3,
.group-video-grid.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.group-video-grid.grid-5,
.group-video-grid.grid-6 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.group-video-grid.grid-more { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }

.participant-tile {
  position: relative;
  background: #1a1a2e;
  border-radius: 10px;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.participant-tile video,
.participant-tile img.tile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.participant-tile .tile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  border: 3px solid rgba(255,255,255,0.2);
}

.participant-tile .tile-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-tile .tile-muted {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(237, 73, 86, 0.9);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.participant-tile.local-tile {
  border: 2px solid var(--ig-blue);
}

.participant-tile .speaking-indicator {
  position: absolute;
  inset: 0;
  border: 3px solid #00c853;
  border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.participant-tile.speaking .speaking-indicator {
  opacity: 1;
}

.group-participants-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  background: rgba(0,0,0,0.35);
}

.group-participants-strip .strip-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid transparent;
  flex-shrink: 0;
}

.group-participants-strip .strip-avatar.active {
  border-color: #00c853;
}

/* Call actions – always at bottom */
.call-overlay .call-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  z-index: 5;
  margin: 0;
}

.call-action-btn.camera-btn.camera-off i {
  background: var(--ig-like);
}

.call-action-btn.invite-btn i {
  background: rgba(255,255,255,0.2);
}

/* Invite modal */
.invite-modal {
  padding: 24px 20px;
  max-height: 70vh;
}

.invite-modal h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.invite-hint {
  font-size: 13px;
  color: var(--ig-secondary);
  margin-bottom: 16px;
}

.invite-list {
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 16px;
}

.invite-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}

.invite-item:hover {
  background: var(--ig-hover);
}

.invite-item img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.invite-item .invite-info {
  flex: 1;
}

.invite-item .invite-info strong {
  display: block;
  font-size: 14px;
}

.invite-item .invite-info span {
  font-size: 12px;
  color: var(--ig-secondary);
}

.invite-item .invite-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--ig-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  transition: all 0.15s;
}

.invite-item.selected .invite-check {
  background: var(--ig-blue);
  border-color: var(--ig-blue);
  color: white;
}

/* Adjust solo call content when video */
#soloCallUI {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 40px 24px 140px;
}

/* ===== Screen share ===== */
.call-action-btn.screen-btn.sharing i {
  background: #00c853;
}

.call-action-btn.link-btn i {
  background: rgba(255,255,255,0.2);
}

.screen-share-banner {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: #00c853;
  color: white;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
}

.screen-share-banner.active {
  display: flex;
}

.screen-share-banner button {
  margin-left: auto;
  background: rgba(0,0,0,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.participant-tile.screen-tile {
  border: 2px solid #00c853;
  transform: translateZ(0);
  will-change: contents;
}

.participant-tile.screen-tile .tile-name::before {
  content: "🖥️ ";
}

/* Screen share video: contain so we don't upscale; reduces fill-rate cost */
.participant-tile.screen-tile video.screen-share-video,
video.screen-share-video {
  object-fit: contain !important;
  background: #0a0a12;
  content-visibility: auto;
}

/* Schedule & Link modals */
.schedule-modal,
.link-modal {
  padding: 24px 20px;
}

.schedule-modal h2,
.link-modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.schedule-modal label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 12px;
}

.schedule-modal input,
.schedule-modal select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ig-border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  background: var(--ig-input-bg);
  color: var(--ig-text);
  font-family: inherit;
}

.schedule-modal input:focus,
.schedule-modal select:focus {
  border-color: var(--ig-blue);
}

.link-box {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.link-box input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--ig-border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--ig-input-bg);
  color: var(--ig-text);
  outline: none;
}

.link-box button {
  flex-shrink: 0;
  padding: 10px 14px;
  white-space: nowrap;
}

.link-note {
  font-size: 12px;
  color: var(--ig-secondary);
  text-align: center;
}

/* Compact call actions on small screens */
@media (max-width: 400px) {
  .call-overlay .call-actions {
    gap: 10px;
  }
  .call-action-btn span {
    font-size: 10px;
  }
  .call-action-btn i {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
}

/* Hardware encoding diagnostics */
.hw-diag-modal {
  padding: 24px 20px;
  max-height: 85vh;
  overflow-y: auto;
}

.hw-diag-modal h2 {
  font-size: 17px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-diag-body {
  font-size: 13px;
  line-height: 1.45;
}

.hw-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ig-border);
}

.hw-section:last-child {
  border-bottom: none;
}

.hw-section h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ig-blue);
}

.hw-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hw-section li {
  padding: 4px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-word;
}

.hw-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.hw-badge.ok {
  background: #e6f4ea;
  color: #137333;
}

.hw-badge.no {
  background: #fce8e6;
  color: #c5221f;
}

.hw-badge.info {
  background: #e8f0fe;
  color: #1967d2;
}

[data-theme="dark"] .hw-badge.ok {
  background: #0d2818;
  color: #81c995;
}

[data-theme="dark"] .hw-badge.no {
  background: #3c1518;
  color: #f28b82;
}

[data-theme="dark"] .hw-badge.info {
  background: #1a2a4a;
  color: #8ab4f8;
}

.hw-loading {
  color: var(--ig-secondary);
  text-align: center;
  padding: 20px;
}

/* ===== Reels (Instagram-style full screen) ===== */
.reels-viewport {
  display: none;
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: 100%;
  height: 100dvh;
  background: #000;
  z-index: 90;
  overflow: hidden;
  touch-action: pan-y;
}

.reels-viewport.active {
  display: block;
}

.reels-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.reel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.reel.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

.reel video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.reel-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.65) 0%,
    rgba(0,0,0,0.15) 35%,
    transparent 55%
  );
}

.reel-right-actions {
  position: absolute;
  right: 12px;
  bottom: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
  z-index: 3;
}

.reel-action {
  background: none;
  border: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.reel-action i {
  font-size: 26px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.45));
}

.reel-action.liked i {
  color: var(--ig-like);
}

.reel-bottom-meta {
  position: absolute;
  left: 14px;
  right: 70px;
  bottom: 70px;
  color: #fff;
  z-index: 3;
  pointer-events: auto;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.reel-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.reel-user img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}

.reel-user strong {
  font-size: 14px;
  font-weight: 600;
}

.reel-user .reel-skill {
  font-size: 12px;
  opacity: 0.9;
  display: block;
}

.reel-caption {
  font-size: 13.5px;
  line-height: 1.35;
  margin-bottom: 10px;
  max-height: 3.2em;
  overflow: hidden;
}

.reel-hire-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ig-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
}

.reels-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.reels-hint.show {
  opacity: 1;
}

/* When reels active, hide main feed chrome slightly */
.app.reels-mode .top-nav,
.app.reels-mode .stories,
.app.reels-mode .feed {
  visibility: hidden;
  pointer-events: none;
}

.app.reels-mode .bottom-nav {
  z-index: 100;
  background: transparent;
  border-top: none;
}

.app.reels-mode .bottom-nav .nav-btn {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.app.reels-mode .bottom-nav .nav-avatar {
  border-color: #fff;
}
