/* swap-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); }

/* ============ SWAP CARD ============ */
.swap-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.sw-head { display: flex; align-items: center; justify-content: space-between; }
.sw-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;
}

.sw-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft, #f8fafc);
}
.sw-boxtop {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  margin-bottom: 6px;
}
.sw-max {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px; font-weight: 800;
  transition: background 0.15s, color 0.15s;
}
.sw-max:hover { background: var(--primary); color: white; }

.sw-line { display: flex; align-items: center; gap: 10px; }
.sw-line input {
  flex: 1; min-width: 0;
  border: 0; background: none; padding: 0;
  font: inherit; font-size: 24px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  outline: none;
}
.sw-line input::placeholder { color: var(--text-muted); }
.sw-line input::-webkit-outer-spin-button,
.sw-line input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sw-line input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.sw-out { flex: 1; min-width: 0; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sw-token {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 800;
}
.sw-bal { display: block; margin-top: 6px; font-size: 11.5px; color: var(--text-muted); }

.sw-fliprow { display: flex; justify-content: center; margin: -4px 0; }
.sw-flip {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--primary-dark);
  display: grid; place-items: center;
  box-shadow: var(--shadow-card);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.sw-flip:hover { background: var(--primary); color: white; transform: rotate(180deg); }

.sw-quote {
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.sw-quote[hidden] { display: none !important; }
.q-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-soft); }
.q-row b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.sw-err { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--danger, #dc2626); }
.sw-err[hidden] { display: none !important; }

.sw-cta {
  padding: 13px;
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-text);
  font-weight: 800; font-size: 15px;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.sw-cta:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.sw-cta:disabled { opacity: 0.45; cursor: not-allowed; }
.sw-note { margin: 0; font-size: 11.5px; line-height: 1.6; color: var(--text-muted); }

/* ============ SWAP RECORDS ============ */
.sw-recscard { padding: 16px 18px; }
.sw-recshead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sw-recshead h2 { font-size: 16px; font-weight: 800; margin: 0; }
.sw-recshead span { font-size: 12px; font-weight: 700; color: var(--text-muted); }

.rec-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rec-ic {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid; place-items: center;
}
.rec-main { flex: 1; min-width: 0; }
.rec-main b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.rec-main small { font-size: 11.5px; color: var(--text-muted); }
.rec-tag {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success, #059669);
  font-size: 11px; font-weight: 800;
}
.rec-empty { margin: 0; padding: 8px 0; font-size: 13px; 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;
}

/* ============ 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; }

  .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; }
}
