/* buy-v1 — self-contained per prototype principle. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 680px) 320px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px; color: var(--text-soft); border-radius: 999px; font-weight: 600; font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active, .sidebar nav a:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.new-post { border-radius: 999px; background: var(--cta-bg); color: var(--cta-text); font-weight: 700; padding: 14px 22px; font-size: 16px; }

/* ============ MAIN ============ */
.main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.topbar .back {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.topbar .back:hover { background: var(--surface-soft); color: var(--text); }
.topbar h1 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.wallet-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.wallet-chip:hover { background: var(--surface); border-color: var(--primary); transform: translateY(-1px); }
.wallet-chip .ic { display: inline-flex; align-items: center; line-height: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }

/* ============ INTRO CARD ============ */
.intro-card {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(180deg, var(--surface), var(--primary-soft));
}
.intro-card .ic {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid; place-items: center;
  font-size: 20px;
  font-weight: 800;
}
.intro-card b { font-size: 15px; }
.intro-card p { margin: 6px 0 0; font-size: 13px; line-height: 1.65; color: var(--text-soft); }
.intro-card p b { font-size: 13px; color: var(--text); }
.inline-link { color: var(--primary-dark); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.inline-link:hover { color: var(--primary); }

/* ============ PARTNERS ============ */
.partners-section { display: flex; flex-direction: column; gap: 10px; }
.partners-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 0;
}
.partners-head h2 { font-size: 16px; font-weight: 800; margin: 0; }
.net-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.partner-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.partner-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.partner-row:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.12);
}
.partner-row:active { transform: translateY(0); }

.p-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 18px;
  font-weight: 800;
  color: white;
}
.p-icon.moon { background: linear-gradient(135deg, #7c3aed, #6366f1); }
.p-icon.trnk { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.p-icon.pbis { background: linear-gradient(135deg, #6366f1, #ec4899); }
.p-icon.grdn { background: linear-gradient(135deg, #10b981, #0ea5e9); }

.p-mid { flex: 1; min-width: 0; }
.p-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.p-name { font-size: 15px; font-weight: 800; }
.p-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft, #f1f5f9);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 700;
}
.p-tag.best { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: var(--success); }
.p-tag.aff  { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
.p-desc { margin-top: 4px; font-size: 12.5px; line-height: 1.55; color: var(--text-soft); }
.p-fee { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--text-muted); }

.p-go {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.partner-row:hover .p-go { background: var(--primary); color: white; }

.disclosure {
  margin: 4px 4px 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ============ RIGHT PANEL ============ */
.right-panel { display: flex; flex-direction: column; gap: 18px; }
.right-panel .card { padding: 18px; }
.right-panel h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
.right-panel p { font-size: 13px; line-height: 1.6; margin: 0 0 8px; color: var(--text); }
.right-panel p:last-child { margin-bottom: 0; }

.tips-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.tips-list li { display: flex; gap: 8px; font-size: 13px; line-height: 1.55; }
.tips-list li::before { content: "·"; color: var(--primary); font-weight: 800; }

.roadmap-card { background: linear-gradient(180deg, var(--surface), var(--primary-soft)); }
.soon-tag {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

/* ============ LEAVE MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.18s;
}
.modal-backdrop.show { opacity: 1; }
.modal-backdrop[hidden] { display: none !important; }

.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-float);
  padding: 20px;
  transform: translateY(10px);
  transition: transform 0.18s;
}
.modal-backdrop.show .modal { transform: translateY(0); }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 17px; font-weight: 800; margin: 0; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-soft);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--surface-soft); color: var(--text); }

.leave-dest {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft, #f8fafc);
  margin-bottom: 12px;
}
.leave-dest b { display: block; font-size: 15px; }
.leave-dest small { color: var(--text-soft); font-size: 12px; }

.leave-points { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.leave-points li {
  display: flex; gap: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-soft);
}
.leave-points li::before { content: "·"; color: var(--primary); font-weight: 800; }

.leave-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.leave-actions button {
  padding: 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  background: var(--surface-soft, #f1f5f9);
  border: 1px solid var(--line);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.leave-actions button:hover { background: var(--line); }
.leave-actions .go { background: var(--cta-bg); color: var(--cta-text); border-color: transparent; }
.leave-actions .go:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* ============ TOAST ============ */
.w-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--text);
  color: white;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-float);
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
}
.w-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.w-toast[hidden] { display: none !important; }

/* ============ BACK TO TOP ============ */
.to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.32);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
}
.to-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (hover: hover) {
  .to-top:hover { background: var(--primary-dark); }
}
.to-top:active { transform: translateY(0) scale(0.94); }

/* ============ MOBILE NAV ============ */
.mobile-nav { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
    padding-bottom: 96px;
    gap: 12px;
  }
  .sidebar, .right-panel { display: none; }

  .topbar {
    position: sticky; top: 0; z-index: 10;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 12px 4px; margin: 0 0 12px;
  }
  .topbar h1 { display: none; }
  .topbar-brand { display: inline-flex; flex: 1; }

  /* Modal becomes bottom sheet */
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal {
    max-width: none;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(24px);
  }

  .mobile-nav {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  }
  .mobile-nav.nav-hidden {
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav a.active { color: var(--text); font-weight: 600; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }

  .to-top {
    bottom: 88px; right: 16px; width: 42px; height: 42px;
    transition: opacity 0.2s, transform 0.2s, background 0.15s,
                bottom 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  body.nav-hidden .to-top { bottom: 28px; }
}
