/* ============================================
   EFCoin — v2: Calm, tab-based, no scroll
   ============================================ */

:root {
  --bg-0: #06070A;
  --bg-1: #0E1016;
  --bg-2: #151821;
  --bg-3: #1F2330;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);

  --text-0: #F5F7FA;
  --text-1: #C9D0DC;
  --text-2: #8A92A3;
  --text-3: #565C6B;

  --accent: #00E676;
  --accent-dim: #00B85F;
  --accent-glow: rgba(0, 230, 118, 0.28);
  --accent-soft: rgba(0, 230, 118, 0.08);

  --magenta: #FF2D8A;
  --magenta-soft: rgba(255, 45, 138, 0.10);

  --gold: #FFC857;
  --success: #22C55E;
  --warn: #F59E0B;
  --error: #EF4444;

  --font-ar: 'Cairo', system-ui, sans-serif;
  --font-en: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 220ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: #030406;
  color: var(--text-0);
  font-family: var(--font-en);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* JS-managed viewport height (falls back to 100dvh then 100vh) so iOS
     Safari's collapsing URL bar doesn't hide the top chrome. */
  height: 100vh;
  height: 100dvh;
  height: var(--app-vh, 100dvh);
}

body[dir="rtl"] { font-family: var(--font-ar); }

.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ===== APP SHELL — full viewport ===== */
body {
  display: block;
  padding: 0;
  /* Same triple-fallback as html */
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-vh, 100dvh);
}
.app-shell {
  width: 100%;
  max-width: none;
  max-height: none;
  background: var(--bg-0);
  border-radius: 0;
  border: none;
  box-shadow: none;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  /* Viewport-accurate height — account for safe areas on notched devices */
  height: 100vh;
  height: 100dvh;
  height: var(--app-vh, 100dvh);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Status bar ===== */
.status-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px 4px;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.status-bar .right { display: flex; gap: 5px; align-items: center; }

/* ===== Top bar ===== */
.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px 12px;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
}
.topbar .brand-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #000;
}
.topbar .brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.topbar .brand-text {
  display: flex; flex-direction: column;
  line-height: 1.1;
}
.topbar .brand-text .t1 { font-size: 10px; color: var(--text-3); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.topbar .brand-text .t2 { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-1);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-0); }

/* ===== Tab bar (top pill tabs) ===== */
.tab-bar {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 0 24px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-bar button {
  padding: 8px 14px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
  border: 1px solid transparent;
}
.tab-bar button:hover { color: var(--text-0); background: var(--bg-2); }
.tab-bar button.active {
  background: var(--accent);
  color: #00160A;
  border-color: var(--accent);
}

/* ===== View container (swaps between tabs) ===== */
.view {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 24px 16px;
  animation: viewIn 240ms var(--ease);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.view-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.view-scroll::-webkit-scrollbar { display: none; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #00160A;
  box-shadow: 0 8px 22px var(--accent-glow);
}
.btn-primary:hover { background: #12F383; }

.btn-ghost {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
}
.btn-ghost:hover { background: var(--bg-3); }

.btn-full { width: 100%; }
.btn-lg { padding: 14px 18px; font-size: 14px; }
.btn-sm { padding: 7px 11px; font-size: 12px; }

/* ===== Cards ===== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}

/* ===== Inputs ===== */
.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-0);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease);
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text-3); }

.label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

/* ===== Pill / Badge ===== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: var(--r-full);
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
}
.pill-accent {
  background: var(--accent-soft);
  border-color: rgba(0,230,118,0.3);
  color: var(--accent);
}

/* ===== Utility ===== */
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack > * + * { margin-top: var(--s, 10px); }
.grow { flex: 1; }
.muted { color: var(--text-2); }
.tiny { font-size: 11px; }
.small { font-size: 13px; }

/* ===== Switch ===== */
.switch {
  position: relative; width: 34px; height: 20px;
  background: var(--bg-3);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  transition: transform var(--dur) var(--ease);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(14px); }

/* ===== Segmented ===== */
.segmented {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.segmented button.active { background: var(--bg-3); color: var(--text-0); }

/* ===== Coin icon ===== */
.coin {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, #FFD76A 0%, #D49527 100%);
  color: #4A2E00; font-size: 10px; font-weight: 900;
  font-family: var(--font-mono);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2) inset;
}
.coin.sm { width: 14px; height: 14px; font-size: 8px; }
.coin.lg { width: 26px; height: 26px; font-size: 13px; }

/* ===== Toast ===== */
.toast-wrap {
  position: fixed; top: 18px; left: 50%;
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toastIn 220ms var(--ease);
}
.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Sheet (modal bottom) ===== */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end;
  animation: pageIn 180ms var(--ease);
}
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  background: var(--bg-1);
  border-top: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 14px 16px 20px;
  animation: sheetIn 260ms var(--ease);
  max-height: 80%;
  overflow-y: auto;
}
@keyframes sheetIn {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--bg-3); margin: 0 auto 10px; }

/* ===== Scrollbar hide ===== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ===== Spinner ===== */
.spinner {
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tweaks panel ===== */
.tweaks-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 300;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 14px;
  width: 240px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  font-size: 12px;
}
[dir="rtl"] .tweaks-panel { right: auto; left: 20px; }
.tweaks-panel h4 {
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
  margin-bottom: 10px;
}

/* Page slide */
.page { animation: viewIn 240ms var(--ease); }
