:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e4e9f1;
  --text: #18202b;
  --muted: #697586;
  --accent: #f7931a;
  --accent-dark: #dd7e0b;
  --accent-soft: #fff4e6;
  --blue: #2f6fed;
  --green: #16784a;
  --shadow: 0 18px 55px rgba(28, 39, 54, .08);
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(247,147,26,.08), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(47,111,237,.05), transparent 30rem),
    var(--bg);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hidden { display: none !important; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 86px; padding: 18px 2px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(145deg, #ffad47, var(--accent)); color: #fff; font-size: 27px; font-weight: 800;
  box-shadow: 0 10px 26px rgba(247,147,26,.22);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 12px; }

.view { padding: 26px 0 36px; }
.hero-card, .panel, .info-card, .modal-card {
  background: rgba(255,255,255,.96); border: 1px solid rgba(225,232,241,.95); box-shadow: var(--shadow);
}
.hero-card { border-radius: 30px; padding: clamp(34px, 7vw, 76px); text-align: center; overflow: hidden; position: relative; }
.hero-card::after {
  content: "₿"; position: absolute; right: -20px; bottom: -82px; font-weight: 900; font-size: 270px;
  color: rgba(247,147,26,.045); pointer-events: none; transform: rotate(10deg);
}
.eyebrow { text-transform: uppercase; letter-spacing: .13em; color: var(--accent-dark); font-size: 11px; font-weight: 800; }
h1 { margin: 12px auto 16px; max-width: 820px; font-size: clamp(38px, 6vw, 72px); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin: 5px 0 0; font-size: 24px; letter-spacing: -.025em; }
.hero-copy { max-width: 720px; margin: 0 auto; color: var(--muted); font-size: 18px; line-height: 1.65; }
.hero-actions { display: flex; justify-content: center; gap: 12px; margin: 28px 0 26px; flex-wrap: wrap; }
.trust-row { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.trust-row span::before { content: "✓"; margin-right: 7px; color: var(--green); font-weight: 800; }

.landing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.info-card { border-radius: var(--radius); padding: 26px; }
.info-card h2 { font-size: 18px; margin: 14px 0 9px; }
.info-card p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.icon-chip { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; }

.btn { border: 0; border-radius: 13px; padding: 13px 19px; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, #ff9f2c, var(--accent-dark)); box-shadow: 0 9px 22px rgba(247,147,26,.18); }
.btn-secondary { color: #283445; background: #eef2f7; }
.btn-ghost { color: #536173; background: transparent; border: 1px solid var(--line); }
.btn-small { padding: 9px 13px; border-radius: 10px; background: #eef2f7; color: #2d3949; }
.btn-block { width: 100%; margin-top: 18px; }

.balance-status-line {
  display: flex; align-items: baseline; gap: 7px; min-height: 18px; margin: 8px 0 2px;
  color: var(--muted); font-size: 12px; line-height: 1.35;
}
.status-progress { color: #8a95a5; }

.wallet-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 16px; }
.panel { border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.compact-head { margin-bottom: 18px; }
.balance-value { margin-top: 8px; font-weight: 850; font-size: clamp(34px, 4vw, 54px); letter-spacing: -.045em; }
.balance-value small { font-size: 18px; color: var(--muted); letter-spacing: 0; }
.balance-panel.balance-loading .balance-value,
.balance-panel.balance-loading .fiat-line,
.balance-panel.balance-loading .balance-meta,
.balance-panel.balance-loading .advanced-balance-list { opacity: .36; filter: grayscale(.35); }
.balance-panel.balance-loading .balance-value { pointer-events: none; user-select: none; }
.fiat-line { color: var(--muted); margin-top: 3px; }
.balance-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.balance-meta div { padding: 13px; border-radius: 12px; background: var(--surface-2); }
.balance-meta span, .balance-meta strong { display: block; }
.balance-meta span { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.balance-meta strong { font-size: 13px; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 12px; font-size: 20px; color: #526173; }

.address-box { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.address-box code { min-width: 0; flex: 1; word-break: break-all; color: #283548; font-size: 13px; }
.muted { color: var(--muted); }
.receive-panel .muted { font-size: 12px; margin: 12px 0 0; }
.select-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.select-control, input, textarea {
  width: 100%; border: 1px solid #dfe5ee; background: #fff; color: var(--text); border-radius: 12px; outline: none;
  padding: 12px 13px; transition: box-shadow .15s ease, border-color .15s ease;
}
input:focus, textarea:focus, select:focus { border-color: rgba(47,111,237,.55); box-shadow: 0 0 0 4px rgba(47,111,237,.08); }
textarea { resize: vertical; }

.send-panel { padding: 28px; }
.available-pill { border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); padding: 8px 12px; color: var(--muted); font-size: 12px; }
.available-pill strong { color: var(--text); margin-left: 5px; }
.form-grid { display: grid; grid-template-columns: 1.4fr .8fr .8fr; gap: 14px; }
.field { display: block; }
.field > span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 750; color: #445165; }
.field small { display: block; color: var(--muted); margin-top: 6px; font-size: 11px; }
.custom-fee-wrap { margin-top: 8px; }
.custom-fee-input { display: flex; align-items: center; gap: 8px; }
.custom-fee-input input { flex: 1; min-width: 0; }
.custom-fee-input span { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 700; }
#customFeeEquivalent { line-height: 1.45; }
.input-with-action { position: relative; }
.input-with-action input { padding-right: 68px; }
.inline-action { position: absolute; right: 6px; top: 6px; bottom: 6px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; font-weight: 850; }
.send-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.fee-summary span, .fee-summary strong { display: block; }
.fee-summary span { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.fee-summary strong { font-size: 14px; }

.mode-switch { display: inline-flex; align-items: center; gap: 8px; color: #526173; font-size: 12px; font-weight: 700; cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 36px; height: 21px; background: #dce3ec; border-radius: 999px; position: relative; transition: background .15s ease; }
.switch-ui::after { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.15); transition: transform .15s ease; }
.mode-switch input:checked + .switch-ui { background: var(--blue); }
.mode-switch input:checked + .switch-ui::after { transform: translateX(15px); }

.bip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.bip-card { padding: 16px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 15px; }
.bip-card span, .bip-card strong, .bip-card small { display: block; }
.bip-card span { color: var(--muted); font-size: 11px; }
.bip-card strong { margin: 8px 0 5px; font-size: 16px; }
.bip-card small { color: #8a95a5; }
.advanced-note { display: grid; grid-template-columns: 190px 1fr; gap: 16px; margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: #f4f7fc; font-size: 12px; line-height: 1.55; }
.advanced-note span { color: var(--muted); }

.history-list { display: grid; gap: 9px; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; }
.history-main { min-width: 0; }
.history-main strong, .history-main small { display: block; }
.history-main strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-main small { color: var(--muted); margin-top: 4px; }
.history-amount { text-align: right; font-weight: 800; font-size: 13px; }
.history-amount.in { color: var(--green); }
.history-amount.out { color: #a24c37; }
.empty-state { text-align: center; color: var(--muted); padding: 28px 8px; background: var(--surface-2); border-radius: 14px; font-size: 13px; }

.footer { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; padding: 10px 0 34px; color: #8b96a5; font-size: 11px; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(25,32,43,.32); backdrop-filter: blur(8px); }
.modal-card { width: min(580px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 24px; padding: 28px; position: relative; }
.small-modal { width: min(470px, 100%); }
.modal-close { position: absolute; right: 14px; top: 13px; width: 34px; height: 34px; border: 0; background: #f0f3f7; color: #536173; border-radius: 10px; font-size: 21px; }
.modal-copy { color: var(--muted); line-height: 1.55; font-size: 13px; }
.seed-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 10px; counter-reset: seed; }
.seed-word { counter-increment: seed; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.seed-word::before { content: counter(seed) "."; display: inline-block; min-width: 22px; color: #9aa4b3; font-size: 10px; }
.confirm-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; color: #4a5667; font-size: 12px; line-height: 1.4; }
.confirm-check input { width: 16px; height: 16px; margin: 1px 0 0; }
.review-table { display: grid; gap: 0; margin: 18px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.review-table > div { display: grid; grid-template-columns: 120px 1fr; gap: 15px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.review-table > div:last-child { border-bottom: 0; }
.review-table span { color: var(--muted); font-size: 12px; }
.review-table code { overflow-wrap: anywhere; font-size: 11px; }
.review-table strong { font-size: 13px; }
.warning-box { padding: 12px 14px; background: #fff8ec; color: #7b5a25; border: 1px solid #f7e3bc; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: 420px; padding: 12px 15px; color: #fff; background: #283444; border-radius: 12px; box-shadow: 0 14px 36px rgba(17,24,39,.2); font-size: 12px; }
.toast.error { background: #9b3427; }
.toast.success { background: #16784a; }

@media (max-width: 900px) {
  .landing-grid, .bip-grid { grid-template-columns: 1fr 1fr; }
  .wallet-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 1180px); }
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: flex-end; gap: 8px; }
  .hero-card { padding: 34px 22px; }
  h1 { font-size: 40px; }
  .landing-grid, .bip-grid, .form-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .balance-panel .panel-head { flex-direction: row; }
  .send-footer { align-items: stretch; flex-direction: column; }
  .send-footer .btn { width: 100%; }
  .seed-box { grid-template-columns: 1fr 1fr; }
  .advanced-note { grid-template-columns: 1fr; gap: 6px; }
  .review-table > div { grid-template-columns: 92px 1fr; }
}

/* v2 wallet refinements */
body, .panel, .topbar, .footer, .address-box, .advanced-receive-row, .balance-meta div {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.wallet-grid { grid-template-columns: 1fr 1fr; }
.balance-main-column { min-width: 0; flex: 1; }
.balance-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 13px; }
.balance-icon-row { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; flex: 0 0 auto; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.balance-mode-switch { white-space: nowrap; }

.advanced-balance-list { display: grid; gap: 5px; margin: 15px 0 13px; max-width: 100%; }
.advanced-balance-row {
  display: grid; grid-template-columns: minmax(145px, 1.05fr) minmax(88px, .8fr) auto; gap: 9px; align-items: center;
  min-height: 28px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
  font-size: 10px;
}
.advanced-balance-row span { color: var(--muted); font-weight: 700; white-space: nowrap; }
.advanced-balance-row code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #596679; font-size: 9px; }
.advanced-balance-row strong { text-align: right; font-size: 10px; white-space: nowrap; }
.advanced-balance-row em { color: var(--green); font-style: normal; font-size: 9px; }
.default-format-row { border-color: rgba(247,147,26,.35); background: rgba(247,147,26,.06); }

.qr-btn, .mini-icon-btn {
  display: inline-grid; place-items: center; border: 1px solid var(--line); background: #fff; color: #455367;
  border-radius: 10px; font-weight: 800; cursor: pointer;
}
.qr-btn { width: 38px; height: 36px; font-size: 18px; flex: 0 0 auto; }
.mini-icon-btn { width: 32px; height: 32px; font-size: 15px; }
.mini-icon-btn.qr { font-size: 17px; }

.advanced-receive-list { display: grid; gap: 8px; }
.advanced-receive-row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2);
}
.receive-format strong, .receive-format small { display: block; }
.receive-format strong { font-size: 11px; }
.receive-format small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.advanced-receive-row code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: #344154; }
.receive-row-actions { display: flex; gap: 6px; }
.default-receive-row { border-color: rgba(247,147,26,.48); box-shadow: inset 3px 0 0 var(--accent); }
.default-receive-row .receive-format strong { font-weight: 850; }
.default-check { color: var(--green); font-size: 9px; font-weight: 800; }

.qr-modal-card { text-align: center; }
.qr-frame { display: grid; place-items: center; min-height: 274px; margin: 18px auto 14px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.qr-frame img { width: 240px; height: 240px; max-width: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-address { display: block; padding: 11px; border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; font-size: 10px; }

/* Advanced mode is intentionally visually darker, while remaining a light theme. */
body.advanced-mode {
  --bg: #dfe4eb;
  --surface: #e8ecf1;
  --surface-2: #dce2e9;
  --line: #c7ced8;
  --text: #17202c;
  --muted: #566274;
  background:
    radial-gradient(circle at 12% 0%, rgba(247,147,26,.07), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(47,111,237,.05), transparent 30rem),
    var(--bg);
}
body.advanced-mode .panel {
  background: rgba(232,236,241,.97);
  border-color: #c4ccd6;
  box-shadow: 0 18px 48px rgba(28,39,54,.10);
}
body.advanced-mode .address-box,
body.advanced-mode .advanced-receive-row,
body.advanced-mode .balance-meta div,
body.advanced-mode .advanced-balance-row,
body.advanced-mode .available-pill,
body.advanced-mode .empty-state {
  background: #d9dfe7;
  border-color: #c2cad5;
}
body.advanced-mode input,
body.advanced-mode textarea,
body.advanced-mode select,
body.advanced-mode .icon-btn,
body.advanced-mode .qr-btn,
body.advanced-mode .mini-icon-btn {
  background: #eef1f5;
  border-color: #c2cad5;
}
body.advanced-mode #normalReceiveBox { display: none; }
body.advanced-mode .default-receive-row,
body.advanced-mode .default-format-row { background: #e6e1d8; }

@media (max-width: 900px) {
  .wallet-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .advanced-receive-row { grid-template-columns: 1fr auto; }
  .advanced-receive-row code { grid-column: 1 / -1; grid-row: 2; white-space: normal; overflow-wrap: anywhere; }
  .receive-row-actions { grid-column: 2; grid-row: 1; }
  .advanced-balance-row { grid-template-columns: 1fr auto; }
  .advanced-balance-row code { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 620px) {
  .balance-panel .panel-head { gap: 10px; }
  .balance-controls { gap: 10px; }
  .balance-mode-switch > span:last-child { display: none; }
  .advanced-balance-row { font-size: 9px; }
  .qr-frame { min-height: 230px; }
  .qr-frame img { width: 210px; height: 210px; }
}

/* Keep full advanced receive addresses visible rather than truncating them. */
.advanced-receive-row code {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* v3 visual refinements */
.mode-switch input:checked + .switch-ui { background: var(--accent); }

/* Advanced switch in the balance panel sits above the balance at top-left. */
.balance-main-column > .balance-mode-switch {
  width: fit-content;
  margin: 0 0 14px;
}
.balance-controls { justify-content: flex-start; }

/* Icon-only wallet controls. */
.wallet-close-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}
.wallet-close-btn svg,
.qr-btn svg,
.mini-icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}
.wallet-close-btn svg { width: 20px; height: 20px; }

/* Normal mode: show the receive address plainly, with actions immediately after it. */
body:not(.advanced-mode) #normalReceiveBox {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  gap: 7px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
body:not(.advanced-mode) #normalReceiveBox code {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 600;
  word-break: break-all;
}
body:not(.advanced-mode) #normalReceiveBox .mini-icon-btn,
body:not(.advanced-mode) #normalReceiveBox .qr-btn {
  flex: 0 0 auto;
}
.normal-copy-btn { width: 38px; height: 36px; }

@media (max-width: 620px) {
  body:not(.advanced-mode) #normalReceiveBox code { font-size: 14px; }
}
