:root {
  --bg:        #070b12;
  --pane:      #0e1421;
  --pane-2:    #131b2b;
  --line:      #1e2941;
  --line-soft: #172032;
  --text:      #eaf0fa;
  --muted:     #7d8ba5;
  --brand:     #34a2ff;
  --brand-2:   #7b5cff;
  --mint:      #17d1a0;
  --warn:      #ffb020;
  --bad:       #ff6b6b;
  --r:         20px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  direction: ltr;
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- نورهای پس‌زمینه ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .5;
  animation: drift 22s ease-in-out infinite;
}
.aurora span:nth-child(1) { width: 420px; height: 420px; background: #1c5fb0; top: -120px; right: -80px; }
.aurora span:nth-child(2) { width: 380px; height: 380px; background: #5b3fd6; top: 30%; left: -140px; animation-delay: -7s; }
.aurora span:nth-child(3) { width: 340px; height: 340px; background: #0f7a63; bottom: -120px; right: 10%; animation-delay: -14s; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(-30px, 40px) scale(1.12); }
  66%      { transform: translate(40px, -30px) scale(.92); }
}
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } }

/* ---------- نوارِ بالا ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; max-width: 1100px; margin: 0 auto;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand img { width: 40px; height: 40px; border-radius: 13px; object-fit: cover; }
.brand b { display: block; font-size: 16px; line-height: 1.4; }
.brand small { color: var(--muted); font-size: 12px; }

main { max-width: 480px; margin: 0 auto; padding: 8px 16px 90px; }

/* ---------- کارتِ سوآپ ---------- */
.swap {
  background: linear-gradient(180deg, rgba(20,28,45,.92), rgba(12,17,28,.94));
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 18px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.05);
}

.swap-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding: 0 4px;
}
.swap-head h1 { font-size: 19px; margin: 0; }
.net-badge {
  font-size: 12px; color: var(--brand);
  background: rgba(52,162,255,.12); border: 1px solid rgba(52,162,255,.3);
  padding: 4px 12px; border-radius: 999px;
}

/* ---------- پنل‌های می‌دهی / می‌گیری ---------- */
.pane {
  background: var(--pane);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 14px 16px;
  transition: border-color .18s;
}
.pane:focus-within { border-color: rgba(52,162,255,.5); }
.pane.out { background: linear-gradient(160deg, rgba(23,209,160,.07), rgba(14,20,33,.9)); }

.pane-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--muted); margin-bottom: 6px;
}
.bal { display: flex; align-items: center; gap: 7px; }
.max {
  background: rgba(52,162,255,.14); color: var(--brand);
  border: 0; border-radius: 7px; padding: 2px 9px;
  font-size: 11px; font-family: inherit; cursor: pointer;
}
.max:hover { background: rgba(52,162,255,.26); }

.pane-row { display: flex; align-items: center; gap: 10px; }

#amount, .amount-out {
  flex: 1; min-width: 0;
  font-size: 30px; font-weight: 600;
  background: none; border: 0; color: var(--text);
  font-family: inherit; padding: 2px 0;
}
#amount:focus { outline: none; }
#amount::placeholder { color: #3c4763; }
.amount-out { color: var(--mint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pane-bot { font-size: 12px; color: var(--muted); min-height: 18px; margin-top: 4px; }

/* ---------- انتخابگرِ توکن ---------- */
.token-pick, .token-fixed {
  display: flex; align-items: center; gap: 7px;
  background: var(--pane-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px 7px 9px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--text); white-space: nowrap;
}
.token-pick { cursor: pointer; transition: .16s; }
.token-pick:hover { background: #182133; border-color: #2a3750; }
.chev { width: 11px; height: 8px; color: var(--muted); }

.coin {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: -.3px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #04101d; flex: none;
}
.coin.tok  { background: linear-gradient(135deg, var(--mint), #0e9e7a); color: #04211a; font-size: 13px; }
/* وقتی لوگوی واقعی داریم، پس‌زمینهٔ گرادیان لازم نیست. */
.coin.logo { background: none; }
.coin svg, .coin img { width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover; }

/* ---------- فلشِ وسط ---------- */
.arrow {
  width: 38px; height: 38px; margin: -9px auto; position: relative; z-index: 2;
  background: var(--pane-2); border: 4px solid #0b111c;
  border-radius: 13px; display: grid; place-items: center;
  color: var(--brand);
}
.arrow svg { width: 15px; height: 15px; }

/* هشدارِ کمبودِ TON برای کارمزد؛ پرداختِ USDT هم TON لازم دارد */
.pane-bot { display: flex; justify-content: space-between; gap: 8px; }
.fee-warn { color: var(--warn); }

/* ---------- جزئیات ---------- */
.details {
  margin: 14px 2px 0; font-size: 12.5px;
  border-top: 1px solid var(--line-soft); padding-top: 12px;
}
.details div { display: flex; justify-content: space-between; padding: 3px 0; }
.details span { color: var(--muted); }
.details b { font-weight: 500; }

/* ---------- دکمهٔ اصلی ---------- */
.cta {
  width: 100%; margin-top: 16px; padding: 16px;
  font-size: 16px; font-weight: 700; font-family: inherit;
  color: #04101d; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 28px -10px rgba(52,162,255,.7);
  transition: .18s;
}
.cta:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.cta:active:not(:disabled) { transform: translateY(0); }
.cta:disabled {
  background: var(--pane-2); color: var(--muted);
  box-shadow: none; cursor: not-allowed;
}

/* ---------- پیام‌ها ---------- */
.msg { margin-top: 12px; padding: 12px 14px; border-radius: 13px; font-size: 13.5px; display: none; white-space: pre-wrap; }
.msg.show { display: block; }
.msg.err  { background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.3); color: #ffb3b3; }
.msg.ok   { background: rgba(23,209,160,.1); border: 1px solid rgba(23,209,160,.3); color: #8ceccd; }
.msg.info { background: rgba(52,162,255,.1); border: 1px solid rgba(52,162,255,.3); color: #a9cef0; }

.notice {
  padding: 14px 16px; border-radius: 15px; font-size: 14px; margin-bottom: 16px;
  background: rgba(255,176,32,.09); border: 1px solid rgba(255,176,32,.28); color: #ffd48a;
}

/* ---------- نوارِ آمار ---------- */
.strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin-top: 16px; background: var(--line-soft);
  border: 1px solid var(--line-soft); border-radius: 17px; overflow: hidden;
}
.strip div { background: rgba(14,20,33,.85); padding: 13px 6px; text-align: center; }
.strip b { display: block; font-size: 15px; }
.strip span { color: var(--muted); font-size: 11px; }

/* ---------- کارت‌ها ---------- */
.card {
  margin-top: 16px; padding: 18px;
  background: rgba(14,20,33,.8); border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card p { color: var(--muted); font-size: 13.5px; margin: 0; white-space: pre-wrap; }

.contract { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12px; }
.contract span { color: var(--muted); flex: none; }
.contract code {
  flex: 1; min-width: 0;
  font-size: 11px; background: var(--pane); padding: 8px 10px;
  border-radius: 9px; border: 1px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contract button {
  background: var(--pane-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 12px; font-size: 12px;
  font-family: inherit; cursor: pointer; flex: none;
}
.contract button:hover { color: var(--text); }

/* ---------- سفارش‌ها ---------- */
.order {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--pane); border: 1px solid var(--line-soft); border-radius: 14px;
}
.order .ref { font-family: ui-monospace, monospace; font-size: 12.5px; }
.order small { color: var(--muted); font-size: 12px; }

.pill { font-size: 11.5px; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.pill.pending { background: rgba(255,176,32,.14); color: var(--warn); }
.pill.paid,
.pill.sending { background: rgba(52,162,255,.14); color: var(--brand); }
.pill.done    { background: rgba(23,209,160,.14); color: var(--mint); }
.pill.expired,
.pill.failed  { background: rgba(255,107,107,.14); color: var(--bad); }

/* ---------- مودال ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4,7,13,.75); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-box {
  width: 100%; max-width: 380px;
  background: #101724; border: 1px solid var(--line);
  border-radius: 22px; padding: 16px;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.9);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head b { font-size: 15px; }
.modal-head button {
  background: none; border: 0; color: var(--muted);
  font-size: 17px; cursor: pointer; padding: 4px 8px;
}
.opt {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; margin-bottom: 8px;
  background: var(--pane); border: 1px solid var(--line-soft);
  border-radius: 15px; cursor: pointer; font-family: inherit;
  color: var(--text); text-align: left; transition: .15s;
}
.opt:hover { background: var(--pane-2); border-color: #2a3750; }
.opt div { flex: 1; }
.opt b { display: block; font-size: 14.5px; }
.opt small { color: var(--muted); font-size: 11.5px; }
.opt em { color: var(--muted); font-size: 12px; font-style: normal; }
.opt:disabled { opacity: .35; cursor: not-allowed; }

.hide { display: none !important; }

/* دکمهٔ خودِ TON Connect با بقیهٔ صفحه هماهنگ شود */
#ton-connect button { font-family: Inter, sans-serif !important; }
