:root {
  --bg: #0F1220;
  --surface: #1A1E31;
  --surface-alt: #252A42;
  --primary: #8B5CF6;
  --primary-alt: #EC4899;
  --text: #F4F3FA;
  --text-muted: #9C9CC0;
  --border: #2E3350;
  --danger: #FF5C7A;
  --gold: #F5C24C;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  direction: rtl;
}

.view { display: none; min-height: 100vh; }
.view.active { display: block; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 24px;
}
.centered { text-align: center; }

.logo-slot { display: flex; justify-content: center; margin-bottom: 12px; }

.brand-title {
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-alt));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 4px 0;
}

.muted { color: var(--text-muted); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin: 20px 0;
  text-align: right;
}
.card h3 { margin-top: 0; font-size: 16px; }
.bullet { font-size: 13px; color: var(--text-muted); line-height: 1.7; margin: 6px 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin: 10px 0;
  font-size: 14px;
  cursor: pointer;
}
.check-row input { width: 18px; height: 18px; }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-gold { background: var(--gold); color: #241a00; }
.btn-link { background: transparent; color: var(--text-muted); font-weight: 500; }
.btn-tiny { width: auto; padding: 8px 14px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); border-radius: 20px; font-weight: 600; font-size: 13px; }

.section-label { font-size: 13px; color: var(--text-muted); margin: 18px 0 8px; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); font-weight: 700; }
.chip.locked { opacity: 0.5; }

.text-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  margin-top: 6px;
  direction: rtl;
}
textarea.text-input { min-height: 70px; resize: vertical; font-family: inherit; }
.flex1 { flex: 1; }

.avatar-preview {
  width: 120px;
  height: 120px;
  border-radius: 60px;
  overflow: hidden;
  margin: 12px auto;
  border: 2px solid var(--border);
}
.avatar-preview img, .avatar-preview canvas { width: 100%; height: 100%; }

/* Main app shell */
#view-main.active { display: flex; min-height: 100vh; align-items: stretch; }
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-header {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.header-title-wrap { display: flex; align-items: center; }
.header-logo-mobile { display: flex; }
.header-actions { display: flex; flex-direction: row-reverse; gap: 16px; align-items: center; }
.header-actions button { background: none; border: none; cursor: pointer; font-size: 14px; font-weight: 600; }

.tab-page { max-width: 480px; margin: 0 auto; padding: 16px; padding-bottom: 90px; min-height: calc(100vh - 60px); width: 100%; }
.tab-title { font-size: 22px; font-weight: 800; margin: 4px 0 16px; }

.centered-box { text-align: center; padding: 60px 24px; }

/* Bottom tab bar - phone-style navigation, mobile only */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  flex-direction: row-reverse;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 20px;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  cursor: pointer;
}
.nav-btn span { font-size: 20px; }
.nav-btn.active { color: var(--primary); font-weight: 700; }

/* Sidebar navigation, desktop only (hidden by default, see media query) */
.side-nav {
  display: none;
  width: 220px;
  flex-shrink: 0;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.side-nav-logo { display: flex; justify-content: flex-end; padding: 6px 10px 22px; }
.side-nav .nav-btn {
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 15px;
}
.side-nav .nav-btn span { font-size: 18px; }
.side-nav .nav-btn.active { background: var(--surface-alt); }

/* Chat */
.chat-toolbar {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.link-danger { background: none; border: none; color: var(--danger); font-weight: 600; cursor: pointer; }
.link-primary { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; }

.messages { display: flex; flex-direction: column; gap: 8px; padding: 12px 4px; min-height: 300px; max-height: 55vh; overflow-y: auto; }
.bubble { max-width: 78%; border-radius: 16px; padding: 10px 14px; font-size: 15px; }
.bubble.mine { align-self: flex-start; background: var(--primary); color: #fff; }
.bubble.theirs { align-self: flex-end; background: var(--surface-alt); color: var(--text); }
.bubble.system { align-self: center; color: var(--text-muted); font-size: 12px; background: none; }
.bubble img { max-width: 220px; border-radius: 12px; display: block; cursor: pointer; }
.bubble img.blurred { filter: blur(20px); }
.bubble audio { max-width: 220px; }

.typing-indicator { color: var(--text-muted); font-size: 12px; padding: 0 8px 6px; }

.chat-input-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-top: 1px solid var(--border);
}
.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 20px;
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
}

/* Friends */
.friend-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.friend-avatar { width: 44px; height: 44px; border-radius: 22px; overflow: hidden; }
.online-dot { width: 10px; height: 10px; border-radius: 5px; background: #22C55E; }

/* Wall */
.compose-box { margin-bottom: 10px; }
.error-text { color: var(--danger); font-size: 12px; text-align: center; margin-bottom: 8px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.post-header { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; }
.post-avatar { width: 36px; height: 36px; border-radius: 18px; overflow: hidden; }
.post-text { font-size: 15px; margin: 8px 0 10px; }
.post-actions { display: flex; flex-direction: row-reverse; gap: 20px; }
.post-actions button { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.post-actions button.liked { color: var(--danger); }
.delete-link { background: none; border: none; color: var(--danger); font-size: 12px; cursor: pointer; }

.comments-list { max-height: 300px; overflow-y: auto; margin-bottom: 10px; }
.comment-row { display: flex; flex-direction: row-reverse; align-items: center; gap: 10px; margin-bottom: 10px; }
.comment-avatar { width: 26px; height: 26px; border-radius: 13px; overflow: hidden; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 22px;
  width: 100%;
  max-width: 480px;
}
.modal-actions { display: flex; flex-direction: row-reverse; justify-content: space-between; margin-top: 16px; }
.premium-banner {
  background: #2A2340;
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.gold-text { color: var(--gold); }

/* Distance filter controls */
.distance-row { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.switch-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 14px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; }
#distance-slider { width: 100%; accent-color: var(--primary); }
#distance-slider:disabled { opacity: 0.4; }

/* ------------------------------------------------------------
   Desktop layout: a real web-app shell (sidebar + wide content),
   not a phone frame stretched to fill the screen.
   ------------------------------------------------------------ */
@media (min-width: 900px) {
  body { background: var(--bg); }

  /* Welcome / profile-setup screens: a centered card, not edge-to-edge */
  #view-welcome.active .container,
  #view-profile.active .container {
    max-width: 520px;
    margin-top: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  }

  .side-nav { display: flex; }
  .bottom-nav { display: none; }
  .header-logo-mobile { display: none; }

  .app-header { padding: 18px 32px; }
  .tab-page { max-width: 760px; padding: 28px 32px; padding-bottom: 40px; min-height: auto; }
  .centered-box { padding: 100px 24px; }

  .modal-backdrop { align-items: center; }
  .modal-card { border-radius: 20px; max-width: 440px; }

  .messages { max-height: 60vh; }
}
