/* GB Share Market Image — modal + preview card */
.gb-share-overlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.gb-share-overlay.open {
  opacity: 1;
  visibility: visible;
}
.gb-share-modal {
  width: 100%;
  max-width: 520px;
  max-height: 96vh;
  overflow: auto;
  background: var(--card, #111a2e);
  color: var(--text, #f1f5f9);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
  padding: 18px 16px 24px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.gb-share-overlay.open .gb-share-modal {
  transform: translateY(0);
}
@media (min-width: 540px) {
  .gb-share-overlay {
    align-items: center;
    padding: 16px;
  }
  .gb-share-modal {
    border-radius: 20px;
    transform: translateY(16px) scale(0.98);
  }
  .gb-share-overlay.open .gb-share-modal {
    transform: translateY(0) scale(1);
  }
}

.gb-share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.gb-share-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}
.gb-share-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line, rgba(148, 163, 184, 0.2));
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.gb-share-ratios {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  background: var(--card2, #18233c);
  border-radius: 12px;
  padding: 4px;
}
.gb-share-ratios button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted, #94a3b8);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 6px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.gb-share-ratios button.active {
  background: linear-gradient(135deg, var(--brand1, #818cf8), var(--brand2, #c084fc));
  color: #fff;
}

.gb-share-preview-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  overflow: hidden;
}
.gb-share-card {
  --gb-share-w: 320px;
  --gb-share-h: 320px;
  width: var(--gb-share-w);
  height: var(--gb-share-h);
  max-width: 100%;
  flex: none;
  box-sizing: border-box;
  overflow: hidden;
  background: linear-gradient(160deg, #0b1120 0%, #111827 45%, #0f172a 100%);
  border-radius: 16px;
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  color: #f8fafc;
  font-family: IRANYekanX, Vazirmatn, Tahoma, sans-serif;
  direction: rtl;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.gb-share-card[data-ratio="landscape"] {
  --gb-share-w: 360px;
  --gb-share-h: 202px;
  padding: 7px 9px 5px;
}
.gb-share-card[data-ratio="square"] {
  --gb-share-w: 320px;
  --gb-share-h: 320px;
  padding: 11px 10px 8px;
}
.gb-share-card[data-ratio="portrait"] {
  --gb-share-w: 280px;
  --gb-share-h: 420px;
  padding: 16px 14px 12px;
}

.gb-share-card-head {
  flex: none;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.25;
  overflow: hidden;
}
.gb-share-card[data-ratio="landscape"] .gb-share-card-head {
  margin-bottom: 3px;
}
.gb-share-card[data-ratio="square"] .gb-share-card-head {
  margin-bottom: 6px;
}
.gb-share-card-head .gb-share-brand {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gb-share-card[data-ratio="landscape"] .gb-share-card-head .gb-share-brand {
  font-size: 0.52rem;
  margin-bottom: 0;
}
.gb-share-card[data-ratio="square"] .gb-share-card-head .gb-share-brand {
  font-size: 0.62rem;
}
.gb-share-card-head .gb-share-time {
  font-size: 0.58rem;
  color: #94a3b8;
  direction: rtl;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gb-share-card[data-ratio="landscape"] .gb-share-card-head .gb-share-time {
  font-size: 0.42rem;
}
.gb-share-card[data-ratio="square"] .gb-share-card-head .gb-share-time {
  font-size: 0.5rem;
}

.gb-share-grid {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  gap: 6px;
  overflow: hidden;
  align-content: stretch;
}
.gb-share-card[data-ratio="landscape"] .gb-share-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.gb-share-card[data-ratio="square"] .gb-share-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.gb-share-card[data-ratio="portrait"] .gb-share-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.gb-share-tile {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 8px;
  padding: 6px 6px 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  justify-content: center;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile {
  padding: 3px 4px 2px;
  gap: 1px;
  border-radius: 5px;
}
.gb-share-card[data-ratio="square"] .gb-share-tile {
  padding: 4px 5px 3px;
  gap: 2px;
  border-radius: 6px;
}
.gb-share-tile-top {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: none;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile-top {
  gap: 3px;
}
.gb-share-tile-ico {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile-ico {
  width: 14px;
  height: 14px;
}
.gb-share-card[data-ratio="square"] .gb-share-tile-ico {
  width: 17px;
  height: 17px;
}
.gb-share-tile-ico img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gb-share-tile-ico svg {
  width: 12px;
  height: 12px;
  stroke: #fbbf24;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile-ico svg {
  width: 9px;
  height: 9px;
}
.gb-share-card[data-ratio="square"] .gb-share-tile-ico svg {
  width: 10px;
  height: 10px;
}
.gb-share-tile-name {
  font-size: 0.54rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile-name {
  font-size: 0.38rem;
}
.gb-share-card[data-ratio="square"] .gb-share-tile-name {
  font-size: 0.46rem;
}
.gb-share-tile-price {
  font-size: 0.66rem;
  font-weight: 700;
  direction: ltr;
  text-align: right;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: none;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile-price {
  font-size: 0.44rem;
  line-height: 1.1;
}
.gb-share-card[data-ratio="square"] .gb-share-tile-price {
  font-size: 0.52rem;
}
.gb-share-tile-unit {
  font-size: 0.44rem;
  color: #94a3b8;
  margin-right: 2px;
}
.gb-share-card[data-ratio="landscape"] .gb-share-tile-unit {
  font-size: 0.34rem;
}
.gb-share-card[data-ratio="square"] .gb-share-tile-unit {
  font-size: 0.38rem;
}
.gb-share-tile-foot {
  display: flex;
  justify-content: flex-end;
  flex: none;
  min-height: 0;
}
.gb-share-badge {
  font-size: 0.46rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  direction: ltr;
  line-height: 1.3;
  white-space: nowrap;
}
.gb-share-card[data-ratio="landscape"] .gb-share-badge {
  font-size: 0.34rem;
  padding: 0 4px;
}
.gb-share-card[data-ratio="square"] .gb-share-badge {
  font-size: 0.4rem;
  padding: 1px 4px;
}
.gb-share-badge.up {
  color: #34d399;
  background: rgba(52, 211, 153, 0.15);
}
.gb-share-badge.down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.15);
}
.gb-share-badge.flat {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.12);
}

.gb-share-card-foot {
  flex: none;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed rgba(148, 163, 184, 0.15);
  text-align: center;
  font-size: 0.52rem;
  color: #64748b;
  direction: ltr;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.gb-share-card[data-ratio="landscape"] .gb-share-card-foot {
  margin-top: 3px;
  padding-top: 2px;
  font-size: 0.36rem;
}
.gb-share-card[data-ratio="square"] .gb-share-card-foot {
  margin-top: 5px;
  padding-top: 4px;
  font-size: 0.44rem;
}

.gb-share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gb-share-actions button {
  border: none;
  border-radius: 12px;
  padding: 13px 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s, opacity 0.2s;
}
.gb-share-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}
#gb-share-download {
  background: var(--card2, #18233c);
  color: var(--text, #f1f5f9);
  border: 1px solid var(--line, rgba(148, 163, 184, 0.2));
}
#gb-share-btn {
  background: linear-gradient(135deg, var(--brand1, #818cf8), var(--brand2, #c084fc));
  color: #fff;
}
.gb-share-actions button:not(:disabled):hover {
  filter: brightness(1.06);
}

.gb-share-trigger svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* gold.html legacy page — floating trigger */
.gb-share-fab {
  position: fixed;
  left: 16px;
  bottom: 20px;
  z-index: 9000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  color: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.gb-share-fab svg {
  width: 22px;
  height: 22px;
}


/* Android WebView save/share fallback sheet — MUST be above .gb-share-overlay (99990) */
.gb-share-save-sheet{
  position:fixed; inset:0; z-index:2147483000;
  display:none; align-items:flex-end; justify-content:center;
  background:rgba(0,0,0,.78); padding:12px; box-sizing:border-box;
  pointer-events:auto;
}
.gb-share-save-sheet.open{display:flex}
.gb-share-save-panel{
  width:min(520px,100%); max-height:94vh; overflow:auto;
  background:#0f172a; color:#e2e8f0; border-radius:18px 18px 14px 14px;
  border:1px solid rgba(148,163,184,.35); padding:16px 14px 18px;
  box-shadow:0 -12px 48px rgba(0,0,0,.55);
  pointer-events:auto;
}
.gb-share-save-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.gb-share-save-head strong{font-size:1.05rem;font-weight:800}
.gb-share-save-x{
  width:40px;height:40px;border:0;border-radius:12px;background:rgba(148,163,184,.2);
  color:#e2e8f0;font-size:24px;line-height:1;cursor:pointer
}
.gb-share-save-hint{
  font-size:.9rem;line-height:1.85;color:#cbd5e1;margin:0 0 12px;
  background:rgba(42,171,238,.12);border:1px solid rgba(42,171,238,.35);
  border-radius:12px;padding:10px 12px;
}
.gb-share-save-hint b{color:#fff}
.gb-share-save-img-wrap{
  border-radius:14px;overflow:hidden;background:#020617;
  border:1px solid rgba(148,163,184,.25); margin-bottom:14px;
  -webkit-touch-callout:default; /* allow long-press save in WebView */
  user-select:auto;
}
.gb-share-save-img-wrap img{
  display:block;width:100%;height:auto;max-height:52vh;object-fit:contain;
  -webkit-touch-callout:default; pointer-events:auto; touch-action:manipulation;
}
.gb-share-save-actions{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.gb-share-save-actions button{
  border:0;border-radius:12px;padding:12px 8px;font-weight:700;font-size:.8rem;cursor:pointer;
  font-family:inherit
}
#gb-share-save-open{background:#2AABEE;color:#fff}
#gb-share-save-dl{background:linear-gradient(135deg,#818cf8,#c084fc);color:#fff}
#gb-share-save-try{background:rgba(148,163,184,.18);color:#e2e8f0}
@media (max-width:380px){
  .gb-share-save-actions{grid-template-columns:1fr; }
}
