/* =============================================================
   LEAF PROTOCOL — The Grove (dApp)
   Inherits every token from style.css
   ============================================================= */

body { background: var(--bg); }

/* Ambient wash behind the whole app */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%,  rgba(34, 208, 126, 0.16), transparent 62%),
    radial-gradient(ellipse 60% 45% at 88% 8%,  rgba(124, 247, 124, 0.10), transparent 62%),
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(232, 196, 104, 0.05), transparent 66%);
}

.app-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 84px 84px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 10%, transparent 68%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 10%, transparent 68%);
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 600;
  background: rgba(5, 11, 7, 0.78);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}

.appbar-in {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-block: 14px;
}

.appbar .brand { margin-right: 6px; }
.appbar .brand img { filter: drop-shadow(0 0 10px rgba(124, 247, 124, 0.45)); }

.app-nav {
  display: flex;
  gap: 3px;
  margin-right: auto;
  padding: 4px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.app-nav a, .app-nav button {
  padding: 7px 15px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.3s var(--ease), background 0.3s var(--ease);
}
.app-nav a:hover, .app-nav button:hover { color: var(--text); }
.app-nav .on { background: rgba(124, 247, 124, 0.11); color: var(--lime); }

.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: nowrap;
}
.net-pill i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 9px var(--emerald);
}
.net-pill.wrong { border-color: rgba(232, 140, 104, 0.4); color: #F0A882; }
.net-pill.wrong i { background: #F0A882; box-shadow: 0 0 9px #F0A882; }

/* ---------- Demo banner ---------- */
.demo-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  margin-bottom: 26px;
  border-radius: var(--r);
  border: 1px solid rgba(232, 196, 104, 0.28);
  background: linear-gradient(120deg, rgba(232, 196, 104, 0.09), transparent 70%);
  font-size: 0.87rem;
  color: #E7D3A2;
}
.demo-bar svg { width: 17px; height: 17px; flex: none; color: var(--gold); }
.demo-bar b { color: var(--gold); }

/* ---------- Page shell ---------- */
.app-main {
  position: relative;
  z-index: 2;
  padding-block: 34px 90px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}
.page-head h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); }
.page-head p { font-size: 0.92rem; margin-top: 8px; }

/* ---------- Portfolio tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 30px;
}

.tile {
  position: relative;
  padding: 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(168deg, var(--surface-2), var(--surface) 66%);
  overflow: hidden;
}
.tile::after {
  content: '';
  position: absolute;
  top: -60%; right: -20%;
  width: 70%; height: 160%;
  background: radial-gradient(ellipse at center, rgba(124, 247, 124, 0.12), transparent 66%);
  pointer-events: none;
}
.tile-k {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}
.tile-k svg { width: 15px; height: 15px; color: var(--moss); }
.tile-v {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-v .u { font-size: 0.62em; color: var(--muted); margin-left: 5px; letter-spacing: -0.01em; }
.tile-sub { margin-top: 9px; font-size: 0.78rem; color: var(--dim); }

.tile.live .tile-v { color: var(--lime); }
.tile.live .tile-k svg { color: var(--lime); }

/* live pulse dot */
.livedot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: pulse 1.6s ease-in-out infinite;
}

/* ---------- Two-column workspace ---------- */
.work {
  display: grid;
  grid-template-columns: 396px 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(172deg, var(--surface-2), var(--surface) 70%);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.panel-head .hint { font-size: 0.76rem; color: var(--muted); }
.panel-body { padding: 22px; }

.plant-panel { position: sticky; top: 88px; }

/* ---------- Tier selector ---------- */
.tier-pick {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

.tpick {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 14px 13px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg-2);
  text-align: left;
  transition: all 0.35s var(--ease);
}
.tpick:hover { border-color: var(--line-2); background: var(--surface); }
.tpick.on {
  border-color: var(--lime);
  background: linear-gradient(150deg, rgba(124, 247, 124, 0.13), transparent 72%);
  box-shadow: var(--glow-sm);
}
.tpick b {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.tpick .apr {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--lime);
}
.tpick .min { font-size: 0.71rem; color: var(--muted); }
.tpick.on .min { color: var(--text-2); }
/* Informational ladder (not selectable): no pointer, no hover highlight. */
.tpick.ladder { cursor: default; }
.tpick.ladder:not(.on):hover { border-color: var(--line); background: var(--bg-2); }

/* ---------- Amount field ---------- */
.field { margin-bottom: 18px; }
.field-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.field-lbl {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-bal { font-size: 0.78rem; color: var(--muted); }
.field-bal b { color: var(--text-2); font-weight: 500; }

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 16px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.input-wrap:focus-within {
  border-color: var(--line-3);
  box-shadow: 0 0 0 3px rgba(124, 247, 124, 0.09);
}
.input-wrap input {
  flex: 1;
  min-width: 0;
  padding: 12px 0;
  border: 0;
  background: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 1.06rem;
  font-weight: 500;
  color: var(--text);
}
.input-wrap input::placeholder { color: var(--dim); }
.input-wrap .unit {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}
.max-btn {
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--lime);
  transition: all 0.3s var(--ease);
}
.max-btn:hover { background: rgba(124, 247, 124, 0.1); border-color: var(--line-3); }

.field-err { margin-top: 9px; font-size: 0.79rem; color: #F0A882; min-height: 0; }

/* ---------- Yield preview ---------- */
.preview {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 20px;
}
.preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  background: var(--bg-2);
  font-size: 0.86rem;
}
.preview-row span { color: var(--muted); }
.preview-row b {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
}
.preview-row.hi b { color: var(--lime); }

.plant-actions { display: grid; gap: 9px; }
.plant-actions .btn { width: 100%; }

.btn[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Spinner */
.spin {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(4, 16, 7, 0.28);
  border-top-color: #041007;
  animation: spin 0.7s linear infinite;
  flex: none;
}
.btn-ghost .spin { border-color: var(--line-2); border-top-color: var(--lime); }

/* ---------- Grove grid ---------- */
.grove-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
  padding: 22px;
}

.tree-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: linear-gradient(168deg, var(--surface-2), var(--bg-2) 72%);
  overflow: hidden;
  transition: border-color 0.4s var(--ease), transform 0.4s var(--ease);
}
.tree-card:hover { border-color: var(--line-2); transform: translateY(-3px); }

/* Header — circular art + titles, Universe-style */
.tc-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 6px;
}
.tc-avatar {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: radial-gradient(ellipse 62% 62% at 50% 55%, rgba(124, 247, 124, 0.16), transparent 72%);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.tc-avatar img { width: 84%; height: 84%; object-fit: contain; }

.tc-titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tc-eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lime);
}
.tc-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.tc-body { padding: 14px 16px 6px; display: grid; gap: 12px; flex: 1; }
.tc-stat { display: flex; flex-direction: column; gap: 3px; }
.tc-stat span {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.tc-stat b {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
}
.tc-stat b.reward { color: var(--lime); }

.tc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px 8px;
}
.tc-actions .btn { width: 100%; padding: 11px 12px; font-size: 0.82rem; }

.tc-actions { padding-bottom: 16px; }

/* ---------- Empty state ---------- */
.empty {
  padding: 62px 26px;
  text-align: center;
}
.empty img { width: 148px; height: auto; margin: 0 auto 22px; opacity: 0.62; }
.empty h3 { margin-bottom: 9px; }
.empty p { font-size: 0.9rem; max-width: 40ch; margin: 0 auto 24px; }

/* Skeleton */
.skel {
  border-radius: var(--r);
  background: linear-gradient(100deg, var(--surface) 20%, var(--surface-2) 40%, var(--surface) 60%);
  background-size: 260% 100%;
  animation: shimmer 1.5s linear infinite;
  height: 300px;
}
@keyframes shimmer { to { background-position: -260% 0; } }

/* ---------- Activity ---------- */
.activity { margin-top: 20px; }
.act-list { display: grid; }
.act {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 15px 22px;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
}
.act:first-child { border-top: 0; }
.act-ic {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(124, 247, 124, 0.09);
  border: 1px solid var(--line);
}
.act-ic svg { width: 15px; height: 15px; color: var(--lime); }
.act-ic.burn { background: rgba(232, 140, 104, 0.09); }
.act-ic.burn svg { color: #F0A882; }
.act-txt b { font-weight: 500; }
.act-txt small { display: block; color: var(--dim); font-size: 0.76rem; margin-top: 2px; }
.act-amt { font-family: var(--font-mono); font-size: 0.85rem; color: var(--lime); white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 5, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}
.modal-bg.open { opacity: 1; visibility: visible; }

.modal {
  width: min(420px, 100%);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: linear-gradient(168deg, var(--surface-3), var(--surface) 68%);
  box-shadow: 0 40px 90px -30px #000;
  transform: translateY(14px) scale(0.98);
  transition: transform 0.4s var(--ease);
}
.modal-bg.open .modal { transform: none; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 1.08rem; }
.modal-x {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: all 0.3s var(--ease);
}
.modal-x:hover { color: var(--text); background: rgba(124, 247, 124, 0.07); }
.modal-x svg { width: 15px; height: 15px; }
.modal-body { padding: 20px 22px 24px; display: grid; gap: 10px; }

.wallet-opt {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg-2);
  text-align: left;
  transition: all 0.3s var(--ease);
}
.wallet-opt:hover { border-color: var(--line-3); background: var(--surface); transform: translateX(2px); }
.wallet-opt .wi {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(124, 247, 124, 0.1);
  font-size: 1.05rem;
}
.wallet-opt b { display: block; font-size: 0.93rem; font-weight: 600; }
.wallet-opt small { color: var(--muted); font-size: 0.76rem; }

.modal-note {
  margin-top: 6px;
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--dim);
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .work { grid-template-columns: 1fr; }
  .plant-panel { position: relative; top: 0; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app-nav { display: none; }
  .appbar-in { gap: 10px; }
  .appbar .brand { margin-right: auto; }
  .net-pill { display: none; }
  .tiles { grid-template-columns: 1fr; }
  .grove-grid { grid-template-columns: 1fr; padding: 16px; }
  .tier-pick { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
}

/* =============================================================
   LEAF V2 — Grove refinement layer
   ============================================================= */
.app-bg {
  background:
    radial-gradient(ellipse 70% 50% at 18% -8%, rgba(75, 178, 97, .10), transparent 64%),
    radial-gradient(ellipse 55% 42% at 92% 2%, rgba(105, 220, 124, .055), transparent 65%);
}
.app-bg::after { opacity: .38; }

.appbar {
  top: 10px;
  margin-inline: 10px;
  border: 1px solid var(--line-2);
  border-radius: 17px;
  background: rgba(7,11,8,.78);
  box-shadow: 0 16px 50px -38px #000;
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}
.appbar-in { min-height: 62px; padding-block: 8px; }
.app-nav {
  padding: 3px;
  border-radius: 11px;
  background: rgba(255,255,255,.022);
  border-color: rgba(255,255,255,.07);
}
.app-nav a, .app-nav button { border-radius: 8px; padding: 7px 13px; }
.app-nav .on { background: rgba(130,238,145,.075); color: #b9f3bf; }
.net-pill { border-radius: 10px; background: rgba(255,255,255,.02); }

.app-main { padding-top: 58px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: clamp(2.15rem,4vw,3rem); }
.page-head p { color: #87968b; max-width: 62ch; }
.demo-bar { border-radius: 13px; background: rgba(232,196,104,.045); }

.tiles { gap: 10px; }
.tile {
  min-height: 136px;
  padding: 20px;
  border-radius: 17px;
  background: linear-gradient(160deg, rgba(17,26,19,.96), rgba(9,14,10,.96));
  border-color: rgba(209,241,215,.09);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.018);
}
.tile::after { opacity: .5; }
.tile-k { margin-bottom: 18px; color: #77867c; }
.tile-v { font-size: clamp(1.55rem,2.5vw,2.1rem); }
.tile.live { border-color: rgba(130,238,145,.18); }

.work { grid-template-columns: 420px minmax(0,1fr); gap: 14px; }
.panel {
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(16,24,18,.96), rgba(8,13,9,.97));
  border-color: rgba(209,241,215,.09);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.018);
}
.panel-head { padding: 18px 20px; }
.panel-body { padding: 20px; }
.plant-panel { top: 92px; }

.tier-pick { gap: 7px; }
.tpick {
  border-radius: 11px;
  padding: 13px 12px;
  background: rgba(255,255,255,.018);
  border-color: rgba(255,255,255,.065);
}
.tpick:hover { background: rgba(255,255,255,.03); }
.tpick.on { background: rgba(130,238,145,.055); border-color: rgba(130,238,145,.28); box-shadow: none; }
.tpick .apr { color: #aceeb5; }

.input-wrap { border-radius: 12px; background: rgba(0,0,0,.16); }
.input-wrap:focus-within { box-shadow: 0 0 0 3px rgba(130,238,145,.055); }
.max-btn { border-radius: 8px; }

.preview { border-radius: 12px; background: rgba(255,255,255,.045); }
.preview-row { background: #090e0a; padding: 12px 14px; }
.preview-row.hi { background: #0b120d; }
.preview-row.hi b { color: #b9f3bf; }
.modal-note {
  margin-top: 12px;
  padding-top: 13px;
  border-top: 1px solid rgba(255,255,255,.055);
  color: #65736a;
}

.grove-grid { gap: 10px; padding: 18px; }
.tree-card {
  border-radius: 15px;
  background: linear-gradient(160deg, rgba(16,25,18,.96), rgba(8,13,9,.98));
  border-color: rgba(209,241,215,.085);
}
.tree-card:hover { transform: translateY(-2px); border-color: rgba(130,238,145,.18); }
.tc-avatar { border-radius: 18px; width: 72px; height: 72px; background: rgba(130,238,145,.035); }
.tc-eyebrow { color: #9beaa6; }
.tc-stat b.reward { color: #b7f4bd; }

.empty { padding: 72px 28px; }
.empty img { opacity: .8; filter: drop-shadow(0 16px 34px rgba(49,174,77,.13)); }
.activity { margin-top: 14px; }
.act { padding: 14px 20px; }
.act-ic { border-radius: 9px; background: rgba(130,238,145,.055); }

.modal-bg { background: rgba(2,5,3,.82); }
.modal {
  border-radius: 18px;
  background: linear-gradient(160deg, #111a13, #080d09 76%);
  box-shadow: 0 48px 120px -50px #000;
}
.wallet-opt { border-radius: 12px; background: rgba(255,255,255,.018); }
.wallet-opt:hover { transform: none; background: rgba(255,255,255,.035); }
.wallet-opt .wi { border-radius: 9px; }

@media (max-width: 1080px) {
  .work { grid-template-columns: 1fr; }
  .plant-panel { top: 0; }
}
@media (max-width: 720px) {
  .appbar { top: 6px; margin-inline: 6px; border-radius: 14px; }
  .app-main { padding-top: 40px; }
  .page-head { align-items: flex-start; }
  .page-head > .btn { width: 100%; }
  .tiles { grid-template-columns: repeat(2,1fr); }
  .tile { min-height: 124px; }
  .tier-pick { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; }
  .tier-pick { grid-template-columns: 1fr; }
  .appbar .btn-sm { padding-inline: 12px; }
  #connectLabel { display: none; }
}
