:root {
  --bg: #0f172a;
  --fg: #e2e8f0;
  --hint: #94a3b8;
  --accent: #38bdf8;
  --accent-fg: #0f172a;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;

  --card: rgba(255, 255, 255, 0.06);
  --card-soft: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --chip: rgba(255, 255, 255, 0.07);

  --tabbar-h: 60px;
}

[data-mode="light"] {
  --card: rgba(0, 0, 0, 0.04);
  --card-soft: rgba(0, 0, 0, 0.025);
  --border: rgba(0, 0, 0, 0.08);
  --chip: rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  min-height: 100vh;
  padding-bottom: var(--tabbar-h);
}
button, input { font-family: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

/* APP BAR */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  background: var(--bg);
  backdrop-filter: blur(10px);
}
.appbar-left { display: flex; flex-direction: column; }
.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 12px; color: var(--hint); margin-top: 2px; }

.wallet-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 50%;
}
.wallet-pill.connected {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}
.wallet-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--hint);
  flex: none;
}
.wallet-pill.connected .wallet-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

/* CONTENT */
.content {
  max-width: 480px;
  margin: 0 auto;
  padding: 6px 16px 24px;
  display: flex; flex-direction: column; gap: 14px;
}

.view { display: none; flex-direction: column; gap: 14px; }
.view-active { display: flex; }

/* CARD */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.card-soft {
  background: var(--card-soft);
  border-radius: 14px;
  padding: 14px 16px;
}
.card-soft-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--hint);
  margin-bottom: 6px;
}
.card-soft-body { font-size: 13px; line-height: 1.5; }

.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--hint);
}
.badge {
  background: var(--chip);
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  color: var(--fg);
}

/* SWAP CARD (dual-leg) */
.swapcard {
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px;
}
.leg {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.leg-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.leg-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--hint); }
.leg-hint { font-size: 12px; color: var(--hint); }
.leg-body { display: flex; align-items: center; gap: 10px; }
.leg-foot { font-size: 12px; color: var(--hint); margin-top: 6px; min-height: 1em; }

.amount-input {
  flex: 1;
  border: 0; background: transparent; color: var(--fg);
  font-size: 28px; font-weight: 700; outline: none; min-width: 0;
  -moz-appearance: textfield;
}
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-readout {
  flex: 1;
  font-size: 28px; font-weight: 700; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.amount-readout.placeholder { color: var(--hint); font-weight: 600; }

.token-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--fg);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
  flex: none;
}
.token-chip:hover { border-color: var(--accent); }
.caret { font-size: 11px; opacity: 0.7; }

.reverse-btn {
  align-self: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 999px;
  font-size: 16px; font-weight: 700;
  margin: -16px 0;
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease;
}
.reverse-btn:active { transform: rotate(180deg); }

/* TEXT INPUT */
.text-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--fg);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}
.text-input:focus { border-color: var(--accent); }

.hint { font-size: 12px; color: var(--hint); margin-top: 6px; }

/* CHIPS (general) */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--fg);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 500;
}
.chip:hover { border-color: var(--accent); }
.chip-on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.primary {
  appearance: none; border: 0; border-radius: 12px;
  padding: 14px 16px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: var(--accent-fg);
  text-align: center; text-decoration: none;
  display: block; width: 100%; margin-top: 4px;
}
.primary:disabled, .primary.disabled { opacity: 0.55; cursor: not-allowed; }

.ghost-btn {
  appearance: none; border: 1px solid var(--border); background: transparent;
  color: var(--fg);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
}

.muted { color: var(--hint); font-size: 13px; line-height: 1.55; margin: 0 0 12px; }
.bullets { padding-left: 18px; margin: 4px 0 0; font-size: 13px; line-height: 1.6; }
.bullets li { margin-bottom: 4px; color: var(--fg); }

/* QUOTES */
.sub { color: var(--hint); font-size: 12px; margin-bottom: 10px; }
.quote {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 10px;
}
.quote:first-child { margin-top: 0; }
.quote-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.quote-name { font-weight: 600; font-size: 15px; }
.quote-amount { font-weight: 700; font-size: 16px; }
.quote-meta { margin-top: 4px; font-size: 12px; color: var(--hint); }
.quote-flags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.flag {
  font-size: 11px;
  background: var(--chip);
  padding: 4px 8px; border-radius: 999px;
  color: var(--fg);
}
.cta { margin-top: 12px; }

.error {
  color: var(--red);
  font-size: 13px;
  background: rgba(239, 68, 68, 0.1);
  padding: 10px 12px; border-radius: 10px;
}
.empty { color: var(--hint); font-size: 13px; padding: 6px 0; }

/* ORDERS */
.order {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.order:last-child { margin-bottom: 0; }
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.order-status { font-size: 12px; color: var(--hint); }
.order-when { color: var(--hint); font-size: 11px; }
.order-line { font-size: 14px; margin-top: 6px; }
.order-link { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--accent); }

/* WALLET */
.tcb-wrap { margin: 4px 0 0; }
.wallet-state {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.wallet-addr { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--fg); }

.footnote { font-size: 11px; color: var(--hint); padding: 0 4px; line-height: 1.5; }

/* TAB BAR */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.tab {
  appearance: none; border: 0; background: transparent; color: var(--hint);
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 11px;
}
.tab-i { font-size: 20px; line-height: 1; }
.tab-l { font-size: 11px; }
.tab-active { color: var(--accent); }

/* TOKEN PICKER SHEET */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
  animation: slide-up 0.18s ease-out;
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
}
.sheet-title { font-size: 15px; font-weight: 600; }
.sheet-section { display: flex; flex-direction: column; gap: 8px; }
.sheet-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--hint);
}
