/* ===========================================================
   Chia — Shared styles
   =========================================================== */

:root {
  --cream: #F4EFE6;
  --cream-2: #EAE3D4;
  --paper: #FBF8F2;
  --ink: #1A1814;
  --ink-2: #3B3730;
  --muted: #807866;
  --line: #D9D2C2;
  --accent: #4F7A4A;
  /* deep pistachio */
  --accent-2: #B9D49E;
  /* soft pistachio */
  --accent-ink: #1F2E1D;
  --danger: #B0413E;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --radius-xl: 36px;

  --shadow-soft: 0 1px 0 rgba(26, 24, 20, 0.04), 0 8px 24px -12px rgba(26, 24, 20, 0.12);
  --shadow-lift: 0 1px 0 rgba(26, 24, 20, 0.06), 0 20px 40px -20px rgba(26, 24, 20, 0.25);

  --container: 1200px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  line-height: 1.2;
}

p {
  margin: 0 0 1em;
}

/* ===========================================================
   Layout
   =========================================================== */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 640px) {
  .container {
    padding: 0 20px;
  }
}

/* ===========================================================
   Top navigation
   =========================================================== */

.nav {
  padding: 22px 0;
  border-bottom: 1px solid transparent;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: relative;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark.alt {
  background: var(--accent-2);
  color: var(--accent-ink);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 15px;
  color: var(--ink-2);
}

.nav-links a:hover {
  color: var(--ink);
}

.nav-links a.active {
  color: var(--ink);
  font-weight: 600;
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
  }
}

/* ===========================================================
   Buttons
   =========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--ink);
  color: var(--cream);
}

.btn-primary:hover {
  background: var(--accent-ink);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn-secondary:hover {
  background: var(--ink);
  color: var(--cream);
}

.btn-ghost:hover {
  background: var(--paper);
}

.btn-soft {
  background: var(--paper);
  border-color: var(--line);
}

.btn-soft:hover {
  background: var(--cream-2);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 14px;
}

.btn-lg {
  padding: 16px 26px;
  font-size: 16px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
}

/* ===========================================================
   Form controls
   =========================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 122, 74, 0.12);
}

.textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.6;
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

.error-text {
  font-size: 13px;
  color: var(--danger);
  display: none;
}

.field.has-error .input {
  border-color: var(--danger);
}

.field.has-error .error-text {
  display: block;
}

/* ===========================================================
   Footer
   =========================================================== */

.footer {
  margin-top: 0;
  padding: 48px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a:hover {
  color: var(--ink);
}

.footer-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  min-height: 80px;
}

.footer-seal img {
  height: 80px;
  width: auto;
  display: block;
  transition: opacity 0.2s;
}

.footer-seal a:hover img {
  opacity: 0.85;
}

.footer-seal[data-enamad]:empty::before {
  content: "";
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background: linear-gradient(110deg, var(--cream-2) 30%, rgba(255, 255, 255, 0.4) 50%, var(--cream-2) 70%);
  background-size: 200% 100%;
  animation: enamad-shimmer 1.4s infinite linear;
}

@keyframes enamad-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ===========================================================
   Utilities
   =========================================================== */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 20px;
}

.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.muted {
  color: var(--muted);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 24px 0;
}

/* ===========================================================
   Toast (used on dashboard for copy feedback)
   =========================================================== */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--cream);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  box-shadow: var(--shadow-lift);
}

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

/* ===========================================================
   Modal
   =========================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 20, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--paper);
  border-radius: var(--radius-l);
  width: 100%;
  max-width: 520px;
  padding: 32px;
  box-shadow: var(--shadow-lift);
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  font-size: 22px;
  margin-bottom: 4px;
}

.modal-foot {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 8px;
}

.modal-close {
  background: transparent;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  color: var(--muted);
}

.modal-close:hover {
  background: var(--cream-2);
  color: var(--ink);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal .lead {
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.6;
}

/* ===========================================================
   Share grid (used in share modal)
   =========================================================== */

.share-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.share-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  border-radius: 14px;
  background: var(--cream);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
  text-decoration: none;
}

.share-opt:hover {
  transform: translateY(-2px);
  background: var(--cream-2);
}

.share-opt .ico {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.share-opt .ico.insta {
  background: linear-gradient(135deg, #F58529, #DD2A7B, #8134AF);
}

.share-opt .ico.tg {
  background: #2AA1DA;
}

.share-opt .ico.wa {
  background: #25D366;
}

.share-opt .ico.x {
  background: #1A1814;
}

.share-opt .ico.mail {
  background: #6B5BA6;
}

.share-opt .ico.copy {
  background: var(--accent);
}

.share-opt .ico.qr {
  background: var(--ink-2);
}

.share-opt .ico.bio {
  background: linear-gradient(135deg, #FF6F4D, #FFB7D5);
}

/* Copy-link inline field */
.copy-field {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  overflow: hidden;
  margin-bottom: 8px;
}

.copy-field .val {
  flex: 1;
  padding: 12px 14px;
  font-family: 'Vazirmatn', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  direction: ltr;
  text-align: left;
  display: flex;
  align-items: center;
}

.copy-field .cp {
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--cream);
  padding: 0 18px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}

.copy-field .cp:hover {
  background: var(--cream-2);
}

/* ===========================================================
   Switch
   =========================================================== */

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  display: none;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--cream-2);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  right: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked+.slider {
  background: var(--accent);
}

.switch input:checked+.slider::before {
  transform: translateX(-18px);
}

/* ===========================================================
   Setting row (used on profile + settings pages)
   =========================================================== */

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  gap: 24px;
}

.setting-row:last-child {
  border-bottom: 0;
}

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

.setting-row .info .t {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.setting-row .info .d {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.setting-row .ctrl {
  flex-shrink: 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 4px;
}

.panel .panel-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.panel.danger {
  border-color: rgba(176, 65, 62, 0.3);
  background: rgba(176, 65, 62, 0.03);
}

.panel.danger h2 {
  color: var(--danger);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(176, 65, 62, 0.3);
}

.btn-danger:hover {
  background: rgba(176, 65, 62, 0.08);
}

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
}

.btn-danger-solid:hover {
  background: #8e2f2d;
}

/* Theme swatches */
.swatch-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: transform .15s ease;
}

.swatch:hover {
  transform: scale(1.05);
}

.swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--cream);
}

.swatch.selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* QR display */
.qr-display {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.qr-img {
  width: 180px;
  height: 180px;
  background:
    linear-gradient(#000 1px, transparent 1px) 0 0/12px 12px,
    linear-gradient(90deg, #000 1px, transparent 1px) 0 0/12px 12px,
    #fff;
  border-radius: 6px;
  position: relative;
}

.qr-img::before,
.qr-img::after,
.qr-img .qr-eye-3 {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  background: #fff;
  border: 8px solid #000;
  border-radius: 4px;
}

.qr-img::before {
  top: 8px;
  right: 8px;
}

.qr-img::after {
  top: 8px;
  left: 8px;
}

.qr-img .qr-eye-3 {
  bottom: 8px;
  right: 8px;
}

/* ===========================================================
   Mobile — Bottom navigation bar (dashboard pages)
   =========================================================== */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 20px;
  right: 20px;
  background: var(--paper);
  padding: 6px 8px;
  z-index: 60;
  box-shadow: 0 -1px 0 var(--line), 0 -6px 32px -8px rgba(26, 24, 20, 0.1);
  gap: 4px;
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 4px 7px 4px;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-s);
  transition: color .15s, background .15s;
}

.bn-item.active {
  background: var(--accent-2);
  color: var(--accent-ink);
}

.bn-ico {
  font-size: 20px;
  line-height: 1;
}

.bn-lbl {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .bottom-nav {
    display: flex;
    border-radius: var(--radius-m);
  }

  .has-bottom-nav .content {
    padding-bottom: 110px;
  }

  .has-bottom-nav .toast {
    bottom: 76px;
  }

  /* Mobile bar: break out of content padding, go edge-to-edge, round bottom */
  .app .content .mobile-bar {
    margin-top: 0;
    margin-right: 0;
    margin-left: 0;
    margin-bottom: 25px;
    border-radius: var(--radius-m);
    box-shadow: 0 4px 16px -6px rgba(26, 24, 20, 0.12);
    border-bottom: 1px solid var(--line);
    top: 12px !important;
  }

  /* Mobile avatar ring */
  #mb-avatar {
    width: 34px !important;
    height: 34px !important;
    font-size: 13px !important;
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--line);
    flex-shrink: 0;
  }
}

/* ===========================================================
   Mobile — Modal as bottom sheet
   =========================================================== */

@media (max-width: 640px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    max-height: 90vh;
    padding: 24px 20px max(24px, env(safe-area-inset-bottom));
    width: 100%;
    max-width: 100%;
  }

  .share-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===========================================================
   Mobile — Footer
   =========================================================== */

@media (max-width: 640px) {
  .footer {
    margin-top: 30px;
    padding: 36px 0 28px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 14px;
  }

  .footer-seal {
    min-width: 64px;
    min-height: 64px;
  }

  .footer-seal img {
    height: 64px;
  }

  .footer-seal[data-enamad]:empty::before {
    width: 64px;
    height: 64px;
  }
}

/* ===========================================================
   Nav search (header user search)
   =========================================================== */

.nav-search {
  position: relative;
  flex: 1;
  max-width: 320px;
  margin: 0 8px;
}

.nav-search-toggle {
  display: none;
  background: var(--cream);
  border: 1px solid var(--line);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.nav-search-toggle svg {
  width: 18px;
  height: 18px;
}

.nav-search-toggle:hover {
  background: var(--cream-2);
}

.nav-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  height: 40px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.nav-search-box:focus-within {
  border-color: var(--ink-2, var(--ink));
  background: var(--paper, #fff);
}

.nav-search-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.nav-search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 0 10px;
  min-width: 0;
}

.nav-search-box input::placeholder {
  color: var(--muted);
}

.nav-search-box input::-webkit-search-cancel-button {
  display: none;
}

.nav-search-clear {
  background: transparent;
  border: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

.nav-search-clear:hover {
  color: var(--ink);
}

.nav-search-results {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: var(--paper, #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 30;
}

.nav-search-empty {
  padding: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.nav-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: background 0.12s ease;
}

.nav-search-item:last-child {
  border-bottom: 0;
}

.nav-search-item:hover,
.nav-search-item.is-active {
  background: var(--cream);
}

.nav-search-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-search-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-search-initials {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.nav-search-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.nav-search-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-search-username {
  font-size: 12px;
  color: var(--muted);
  direction: ltr;
  text-align: start;
}

.nav-search-meta {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--accent-ink);
  background: var(--accent-2);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .nav-search {
    max-width: 240px;
  }
}

@media (max-width: 720px) {
  .nav-search {
    flex: 0 0 auto;
    margin: 0;
    max-width: none;
    position: static;
  }

  .nav-search-toggle {
    display: inline-flex;
  }

  .nav-search-box {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    transform: none;
    inset-inline: 12px;
    width: auto;
    max-width: none;
    z-index: 25;
    box-shadow: var(--shadow-soft);
    background: var(--paper, #fff);
  }

  .nav-search.is-open .nav-search-box {
    display: flex;
  }

  .nav-search.is-open .nav-search-toggle {
    background: var(--ink);
    color: var(--cream);
    border-color: var(--ink);
  }

  .nav-search-results {
    inset-inline: 12px;
    width: auto;
  }
}