/* Evenkeel mobile density pass (max-width: 767px).
   Drop-in: load after app.css, v2.css and ek.css (landing only).
   Scoped to the production class names already in the live app.
   Colors, borders, shadows and contrast are unchanged.
   Visible controls can be 36px; a 40px hit area is added with ::after
   (WCAG 2.5.8 minimum is 24px). Desktop (≥768px) is untouched. */

@media (max-width: 767px) {
  :root {
    --ek-btn-h-lg: 40px;
    --ek-btn-h-md: 40px;
    --ek-btn-h-sm: 36px;
    --ek-btn-fs: 13px;
    --ek-btn-fs-sm: 13px;
    --ek-btn-lh: 18px;
    --ek-btn-pad-x: 14px;
    --ek-btn-pad-x-sm: 12px;
    --ek-btn-radius: 10px;
    --ek-btn-weight: 520;
    --ek-btn-tracking: -0.01em;
    --ek-btn-gap: 6px;
    --ek-hit: 40px;
  }

  /* ---- Buttons: lg / md / sm ----------------------------------------- */
  /* Beats app.css .btn, v2.css .btn/.btn-lg, and ek.css .btn / .ek .btn.lg
     (ek.css .btn is unscoped and otherwise forces height: 48px / 56px on
     the landing page, including the header). */
  .btn,
  .ek .btn,
  a.btn,
  button.btn {
    height: var(--ek-btn-h-md);
    min-height: var(--ek-btn-h-md);
    padding: 0 var(--ek-btn-pad-x);
    font-size: var(--ek-btn-fs);
    font-weight: var(--ek-btn-weight);
    line-height: var(--ek-btn-lh);
    letter-spacing: var(--ek-btn-tracking);
    border-radius: var(--ek-btn-radius);
    gap: var(--ek-btn-gap);
  }

  .btn-lg,
  .btn.btn-lg,
  .ek .btn.lg,
  .ek .btn.p.lg,
  .ek .btn.s.lg {
    height: var(--ek-btn-h-lg);
    min-height: var(--ek-btn-h-lg);
    padding: 0 var(--ek-btn-pad-x);
    font-size: var(--ek-btn-fs);
    line-height: var(--ek-btn-lh);
    border-radius: var(--ek-btn-radius);
  }

  .btn-sm,
  .btn.btn-sm,
  .ek .btn.sm,
  .nav-right .btn-sm,
  .btn-ghost.btn-sm {
    height: var(--ek-btn-h-sm);
    min-height: var(--ek-btn-h-sm);
    padding: 0 var(--ek-btn-pad-x-sm);
    font-size: var(--ek-btn-fs-sm);
    line-height: var(--ek-btn-lh);
    border-radius: var(--ek-btn-radius);
  }

  .wallet-btn,
  .btn.wallet-btn,
  .wallet-btn.btn-primary,
  .wallet-btn.btn-secondary {
    height: var(--ek-btn-h-sm);
    min-height: var(--ek-btn-h-sm);
    padding: 0 10px;
    font-size: var(--ek-btn-fs-sm);
    line-height: var(--ek-btn-lh);
    border-radius: var(--ek-btn-radius);
  }
  .wallet-btn .i { display: none; }
  .wallet-btn .mono { font-size: 12px; }

  .btn-ghost,
  .link-btn {
    font-size: 13px;
    line-height: var(--ek-btn-lh);
    min-height: var(--ek-hit);
    padding: 4px 6px;
  }

  .btn .i,
  .btn svg,
  .wallet-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Full-width only on form/block actions, not on hero or empty-state pairs. */
  .btn-block,
  .ek .btn.block,
  .form-card .btn,
  #btn-approve,
  #btn-deposit,
  #btn-withdraw,
  #btn-emergency,
  #dep-connect,
  #wd-connect,
  #em-close {
    width: 100%;
  }

  /* ---- 40px hit area on visually smaller controls -------------------- */
  .theme-btn,
  .wallet-btn,
  .btn-sm,
  .max-btn,
  .icon-btn,
  .menu-btn,
  .x-nav {
    position: relative;
  }
  .theme-btn::after,
  .wallet-btn::after,
  .btn-sm::after,
  .max-btn::after,
  .icon-btn::after,
  .menu-btn::after,
  .x-nav::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--ek-hit);
    height: var(--ek-hit);
    transform: translate(-50%, -50%);
    pointer-events: auto;
  }

  /* ---- Header --------------------------------------------------------- */
  /* No hamburger exists in production (v2.css forces .menu-btn { display: none }).
     App pages use the bottom tab bar; landing uses Open app + theme toggle. */
  .nav-inner,
  .container.nav-inner {
    height: 56px;
    gap: 8px;
  }
  .nav { min-height: 56px; }
  .theme-btn,
  .x-nav {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
  }
  .theme-btn svg,
  .x-nav svg { width: 15px; height: 15px; }
  .logo.brand svg,
  .brand svg,
  .ek .logo.brand svg { height: 22px; }
  .brand.wordmark { font-size: 18px; }

  /* ---- Bottom tab bar ------------------------------------------------- */
  .tabbar {
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    gap: 1px;
    padding: 4px 0 2px;
    font-size: 10.5px;
    line-height: 13px;
    font-weight: 500;
    border-radius: 10px;
  }
  .tabbar a svg { width: 18px; height: 18px; }
  body { padding-bottom: 64px; }

  /* ---- Tabs, segmented controls, token pills, Max --------------------- */
  .tabs {
    padding: 3px;
    gap: 3px;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .tab,
  button.tab {
    min-height: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    border-radius: 8px;
  }

  .seg,
  .ek .seg {
    padding: 3px;
    border-radius: 10px;
  }
  .seg label,
  .ek .seg label {
    min-height: 28px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    border-radius: 8px;
  }
  .seg-mini .seg { padding: 2px; border-radius: 10px; }
  .seg-mini .seg label { min-height: 26px; padding: 0 8px; font-size: 12px; }

  .ek .seg-btns,
  .seg.seg-btns {
    padding: 3px;
    border-radius: 10px;
    gap: 2px;
  }
  .ek .seg-btns button {
    padding: 5px 10px;
    font-size: 12px;
    line-height: 16px;
    border-radius: 8px;
  }

  .token-pill {
    height: 32px;
    padding: 0 10px 0 4px;
    font-size: 13px;
    font-weight: 560;
    gap: 6px;
  }
  .token-pill .t-ico, .token-pill img.t-ico { width: 20px; height: 20px; font-size: 10px; }

  .max-btn {
    height: 22px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 22px;
    border-radius: 6px;
  }

  /* ---- Chips, freshness, sample badges -------------------------------- */
  .chip,
  .ek .chip {
    height: 20px;
    min-height: 20px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
    gap: 5px;
  }
  .chip::before { width: 5px; height: 5px; }
  .pill-strip { gap: 6px; }
  .pill-strip .chip {
    height: auto;
    min-height: 22px;
    padding: 3px 8px;
    font-size: 11px;
    white-space: normal;
  }
  .sample,
  .badge-sample {
    height: 18px;
    padding: 0 6px;
    font-size: 10px;
    line-height: 18px;
  }
  .delta {
    height: 18px;
    padding: 0 6px;
    font-size: 11px;
  }
  .fresh { font-size: 11px; }

  /* ---- Inputs / amount boxes ------------------------------------------ */
  .amount,
  .recv {
    padding: 12px 14px;
    border-radius: 14px;
  }
  .amount-input,
  .form-card .amount-input,
  #dep-amount,
  #wd-amount {
    font-size: 28px;
    line-height: 34px;
  }
  .form-card .num-lg,
  .recv .num-lg {
    font-size: 26px;
    line-height: 32px;
  }
  .box-label,
  .box-foot { font-size: 12px; }
  .box-foot { margin-top: 4px; }

  /* ---- Cards, banners, page chrome ------------------------------------ */
  .card,
  .ek .card,
  .ek .card.p32,
  .ek .card.p20 {
    padding: 16px;
    border-radius: 16px;
  }
  .ek .card.p0 { padding: 0; }
  .panel,
  .sub-card,
  .req-card {
    padding: 12px 14px;
    border-radius: 14px;
  }
  .banner { padding: 12px 14px; border-radius: 14px; }
  .preview-ribbon { font-size: 12px; line-height: 18px; }
  .preview-ribbon .container { min-height: 0; padding-top: 6px; padding-bottom: 6px; }

  .page-head {
    padding-top: 16px;
    margin: 8px 0 12px;
  }
  .page-head .lead,
  .page-head .h1 + p { font-size: 14px; line-height: 20px; }

  /* ---- Hero / landing layout ------------------------------------------ */
  .ek .hero-grid.wrap { padding-top: 28px; padding-bottom: 64px; }
  .ek .hero-grid > .col.gap24 { gap: 16px; }
  .ek .hero-lead,
  .ek .lead { font-size: 15px; line-height: 22px; }
  .ek .stat-wrap { margin-top: -36px; }
  .ek .sec.wrap { padding-top: 48px; }
  .ek .sec-last.wrap { padding-bottom: 48px; }
  .ek .cta { padding: 16px; }
  .ek .cta .lead { font-size: 14px; line-height: 22px; }

  /* Hero and other button-only rows: sit inline, do not stretch full width.
     (Production uses .stack-m, which forces a column and align-items: stretch,
     so Deposit + See how it works become two 56px-tall full-width bars.) */
  .ek .stack-m:has(> .btn):not(:has(> :not(.btn))),
  .ek .cta-row,
  .empty-actions {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center !important;
    gap: 8px;
  }
  .ek .stack-m:has(> .btn):not(:has(> :not(.btn))) > .btn,
  .ek .cta-row > .btn,
  .empty-actions > .btn {
    width: auto;
    flex: 0 0 auto;
  }
  /* Title + button rows (e.g. Limits header): keep the button shrink-wrapped. */
  .ek .stack-m > .btn {
    width: auto;
    align-self: flex-start;
    flex: 0 0 auto;
  }

  /* Form card vertical rhythm */
  .form-card > * + * { margin-top: 12px; }
  .form-layout { gap: 12px; }

  /* Empty-state CTAs stay on one row when they fit. */
  .empty-hero { gap: 10px; }
  .empty-actions { margin-top: 8px; }

  /* Wallet picker */
  .wallet-opt {
    min-height: 44px;
    padding: 0 14px;
    font-size: 14px;
    line-height: 20px;
    border-radius: 10px;
  }

  /* Dashboard position CTAs under the empty card (Deposit / Withdraw blocks
     stay full width, just shorter). */
  .span8 .btn-block + .btn-block,
  .card .btn-block + .btn-block { margin-top: 8px; }
}

/* Slightly tighter still on iPhone-width. */
@media (max-width: 480px) {
  .ek .h-hero,
  .ek .h-hero2 { font-size: 36px; line-height: 40px; }
  .amount-input,
  .form-card .amount-input,
  #dep-amount,
  #wd-amount { font-size: 26px; line-height: 32px; }
}
