:root {
  --bg: #05070d;
  --bg-soft: #080b13;
  --card: #0d1119;
  --card-2: #101623;
  --line: #1b2231;
  --line-soft: #151c2a;
  --text: #e9edf6;
  --muted: #7c879b;
  --muted-2: #5d6879;
  --accent: #5b8cff;
  --accent-2: #7a63ff;
  --green: #39d98a;
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(56, 92, 255, 0.22), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(122, 99, 255, 0.16), transparent 60%),
    var(--bg);
  overflow-x: hidden;
}

button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.glow-a { width: 320px; height: 320px; background: rgba(40, 86, 255, 0.18); top: -120px; right: -80px; }
.glow-b { width: 260px; height: 260px; background: rgba(122, 99, 255, 0.12); bottom: -100px; left: -80px; }

.phone {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(104px + var(--safe-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.96) 60%, rgba(5, 7, 13, 0));
  backdrop-filter: blur(10px);
}
.brand {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, #ffffff, #9fb4ff 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #a7b1c4;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: #131a28; color: #fff; }

.menu-pop {
  position: absolute;
  top: 56px;
  right: 14px;
  min-width: 190px;
  background: #121826;
  border: 1px solid #232c3e;
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-pop button,
.menu-pop a {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 9px;
}
.menu-pop button:hover,
.menu-pop a:hover { background: #1a2233; }

/* ---------- layout ---------- */
.content { padding: 2px 14px 0; }
.tab-page { display: flex; flex-direction: column; }

.card {
  background: linear-gradient(180deg, rgba(16, 21, 33, 0.92), rgba(12, 16, 26, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #8d97ab;
}
.green-text { color: var(--green); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.45; }
.warn { color: #ff6961; margin-top: 8px; }
.trial-banner {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(57, 217, 138, 0.08);
  border: 1px solid rgba(57, 217, 138, 0.22);
  color: var(--green);
  font-size: 12px;
  line-height: 1.4;
}
.field[readonly] { color: #9aa4b8; }
.chat-hint { margin: -4px 0 8px; }
.subhead {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #8d97ab;
  margin: 14px 0 8px;
}
.mini-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 4px;
}
.mini-link:hover { color: var(--text); }

/* ---------- profile ---------- */
.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
}
.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(140deg, #2b4bff, #7a63ff 60%, #b44bff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.avatar.small {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  font-size: 13px;
  background: linear-gradient(140deg, #22304d, #2d2350);
}
.profile-meta { min-width: 0; flex: 1; }
.profile-name {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill {
  border: 1px solid #2a3346;
  background: #171e2c;
  color: #dfe6f5;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
}
.pill:hover { background: #1d2637; }

/* ---------- search + chats ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.search svg { width: 16px; height: 16px; color: var(--muted-2); flex: 0 0 16px; }
.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
}
.search input::placeholder { color: #586273; }

.chat-list { display: flex; flex-direction: column; gap: 3px; }
.chat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.chat-row:hover { background: #121926; }
.chat-row.selected { background: #161e2e; border-color: #26324a; }
.chat-row.choose {
  border-color: var(--line-soft);
  background: #0a0e16;
  padding: 11px 12px;
  margin-top: 2px;
}
.chat-row.choose .chat-name { font-weight: 500; }
.chat-meta { flex: 1; min-width: 0; }
.chat-name { font-size: 13px; font-weight: 500; }
.chat-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.chat-check { color: var(--text); width: 16px; height: 16px; flex: 0 0 16px; }
.chat-empty { font-size: 12px; color: var(--muted); padding: 8px 4px; }
#chatState { text-transform: uppercase; letter-spacing: 0.05em; }
.warn-card { border-color: rgba(255, 69, 58, 0.35); }
.gate-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }

/* ---------- form ---------- */
.gift-input {
  width: 100%;
  resize: none;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  outline: none;
  margin-bottom: 8px;
}
.gift-input::placeholder { color: #586273; }
.gift-input:focus, .field:focus { border-color: #34456b; }

.recognized {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 11px 12px;
  margin: -2px 0 8px;
}
.recognized-name { font-size: 13px; }
.recognized-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
}

.field {
  width: 100%;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  margin-bottom: 8px;
}
.field::placeholder { color: #586273; }

.segmented {
  display: flex;
  gap: 4px;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 10px;
}
.segmented button {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #8a94a8;
  font-size: 12px;
  font-weight: 500;
  padding: 9px 6px;
  border-radius: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s;
}
.segmented button.active {
  background: linear-gradient(180deg, #262f41, #202838);
  border-color: #33405a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.primary {
  width: 100%;
  border: 1px solid #3a4356;
  background: linear-gradient(180deg, #333b4c, #262d3b);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 13px;
  border-radius: 12px;
  margin-top: 2px;
  transition: filter 0.15s, transform 0.05s;
}
.primary:hover { filter: brightness(1.12); }
.primary:active { transform: scale(0.994); }
.primary:disabled { opacity: 0.55; cursor: default; filter: none; }

.ghost {
  flex: 1;
  border: 1px solid #2b3447;
  background: linear-gradient(180deg, #1c2433, #171e2b);
  color: #e7ecf7;
  font-size: 12.5px;
  font-weight: 500;
  padding: 11px;
  border-radius: 11px;
}
.ghost:hover { filter: brightness(1.12); }
.ghost.wide { width: 100%; margin-top: 10px; }

.link-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 11px 4px 2px;
}
.link-btn:hover { color: var(--text); }

.hint { font-size: 11.5px; color: var(--muted-2); text-align: center; margin-top: 9px; }

.two-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two-inputs .field { margin-bottom: 0; }

/* ---------- offer preview ---------- */
.offer-preview {
  background:
    radial-gradient(300px 160px at 85% 0%, rgba(64, 98, 255, 0.18), transparent 70%),
    linear-gradient(165deg, #101a2c, #0b1019 75%);
  border-color: #1e2a42;
  display: flex;
  flex-direction: column;
}
.preview-top { display: flex; justify-content: space-between; gap: 10px; }
.preview-copy { min-width: 0; }
.preview-eyebrow { font-size: 11.5px; color: var(--muted); }
.preview-eyebrow span { color: #c9d4e9; font-weight: 600; }
.preview-price { font-size: 15px; font-weight: 600; margin-top: 8px; }
.preview-gift { font-size: 12px; color: var(--muted); margin-top: 3px; }
.preview-time { font-size: 10.5px; color: #93a0b8; white-space: nowrap; padding-top: 2px; }

.gift-card {
  margin: 12px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    radial-gradient(160px 100px at 20% 20%, rgba(120, 200, 255, 0.35), transparent 65%),
    linear-gradient(135deg, #2c4a78 0%, #3c3168 52%, #5c3159 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.gift-art {
  height: 108px;
  display: grid;
  place-items: center;
  font-size: 46px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}
.gift-caption {
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: #dfe7f8;
  padding: 9px;
  background: rgba(5, 9, 18, 0.35);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.preview-actions { display: flex; gap: 8px; }
.preview-actions.column { flex-direction: column; }

.offer-preview.gift-above .preview-top { order: 2; margin-top: 12px; }
.offer-preview.gift-above .gift-card { order: 1; margin-top: 2px; }
.offer-preview.gift-above .preview-actions { order: 3; }

/* ---------- settings ---------- */
.settings-list { display: flex; flex-direction: column; }
.setting { margin-bottom: 13px; }
.setting:last-child { margin-bottom: 4px; }
.setting-label { font-size: 12px; color: #9aa4b8; margin-bottom: 6px; }
.setting .segmented { margin-bottom: 0; }

.badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 7px;
}
.badge.green {
  color: var(--green);
  background: rgba(57, 217, 138, 0.1);
  border: 1px solid rgba(57, 217, 138, 0.25);
}

.payout-list { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.payout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.payout .payout-sub { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.payout .chev { color: var(--muted-2); font-size: 16px; line-height: 1; }
.payout.active { border-color: #3a4c74; background: #121a2b; }
.payout.active .chev { color: var(--accent); }

.balances { display: flex; gap: 8px; flex-wrap: wrap; }
.balance-chip {
  flex: 1;
  min-width: 96px;
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 10px 12px;
}
.balance-chip .balance-value { font-size: 15px; font-weight: 600; }
.balance-chip .balance-label { font-size: 10.5px; color: var(--muted); margin-top: 2px; letter-spacing: 0.06em; }

/* ---------- offers ---------- */
.offer-list { display: flex; flex-direction: column; gap: 8px; }
.offer-item {
  background: #0a0e16;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 11px 12px;
}
.offer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.offer-role { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.offer-title { font-size: 13.5px; font-weight: 600; margin-top: 5px; }
.offer-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.offer-time { font-size: 10.5px; color: #8b98b1; margin-top: 5px; }
.offer-actions { display: flex; gap: 7px; margin-top: 9px; }
.offer-actions button {
  flex: 1;
  border: 1px solid #2b3447;
  background: #182031;
  color: #e6ebf6;
  font-size: 11.5px;
  font-weight: 500;
  padding: 9px 6px;
  border-radius: 9px;
}
.offer-actions button:hover { filter: brightness(1.15); }
.offer-actions button.accent {
  background: linear-gradient(180deg, #2f58d6, #2747b0);
  border-color: #4a6fe0;
  color: #fff;
}
.status {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.status.pending { color: #ffc46b; background: rgba(255, 196, 107, 0.1); }
.status.accepted, .status.awaiting_transfer { color: #7fa8ff; background: rgba(91, 140, 255, 0.12); }
.status.sent { color: #b79cff; background: rgba(150, 120, 255, 0.12); }
.status.completed { color: var(--green); background: rgba(57, 217, 138, 0.1); }
.status.declined, .status.cancelled, .status.expired { color: #98a2b5; background: rgba(152, 162, 181, 0.1); }
.offer-empty { font-size: 12px; color: var(--muted-2); padding: 4px 2px 2px; }

/* ---------- admin ---------- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.admin-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
}
.admin-stat-value { font-size: 16px; font-weight: 700; }
.admin-stat-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-top: 2px;
}
.admin-user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.admin-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.admin-user-meta { min-width: 0; }
.admin-user-actions { display: flex; flex-direction: column; gap: 5px; flex: 0 0 auto; }
.admin-btn {
  border: 1px solid #2a3346;
  background: #171e2c;
  color: #dfe6f5;
  font-size: 10.5px;
  font-weight: 500;
  padding: 6px 9px;
  border-radius: 8px;
  white-space: nowrap;
}
.admin-btn:hover { background: #1d2637; }
.admin-btn:disabled { opacity: 0.4; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: calc(12px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  width: min(452px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  background: rgba(16, 21, 32, 0.94);
  border: 1px solid #232c3e;
  border-radius: 22px;
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.tabbar.admin { grid-template-columns: repeat(4, 1fr); }
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: #79849a;
  font-size: 10px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.tab-btn svg { width: 19px; height: 19px; }
.tab-btn.active { background: #1e2738; color: #fff; }
.tab-btn:hover { color: #cdd6e6; }

/* ---------- toast / fatal ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: min(420px, calc(100% - 40px));
  background: #1b2333;
  border: 1px solid #2c3850;
  color: #eef2fa;
  font-size: 12.5px;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: 11px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fatal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 11, 0.92);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.fatal-box {
  width: min(360px, 100%);
  background: #101623;
  border: 1px solid #243049;
  border-radius: 18px;
  padding: 20px;
  text-align: center;
}
.fatal-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.fatal-text { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 14px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #1f2a3d; border-radius: 8px; }

@media (max-width: 380px) {
  .content { padding: 2px 10px 0; }
  .card { padding: 12px; border-radius: 16px; }
  .segmented button { font-size: 11px; padding: 8px 4px; }
}

/* --- Paywall --- */
.paywall {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 18px calc(22px + var(--safe-bottom));
  background:
    radial-gradient(700px 420px at 50% -10%, rgba(91, 140, 255, 0.18), transparent 65%),
    radial-gradient(600px 380px at 50% 115%, rgba(122, 99, 255, 0.14), transparent 65%),
    rgba(5, 7, 13, 0.96);
  backdrop-filter: blur(14px);
  overflow-y: auto;
}
.paywall.hidden { display: none; }
.paywall-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.paywall-logo {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 2px;
  filter: drop-shadow(0 10px 26px rgba(91, 140, 255, 0.35));
}
.paywall-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.paywall-price {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
  margin: 2px 0 6px;
}
.paywall-period {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.paywall-features {
  list-style: none;
  margin: 0 0 6px;
  padding: 14px 16px;
  text-align: left;
  background: linear-gradient(180deg, rgba(16, 21, 33, 0.92), rgba(12, 16, 26, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.paywall-features li {
  position: relative;
  padding-left: 20px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}
.paywall-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--green);
  font-weight: 700;
}
.paywall-note {
  margin-top: 2px;
  line-height: 1.5;
}
.paywall .primary,
.paywall .ghost {
  width: 100%;
}
body.paywalled .tabbar { display: none; }
body.paywalled .phone { min-height: 100vh; }
