@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/roboto-mono-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 500;
  font-display: block;
  src: url("fonts/material-symbols.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #f9fafb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #eff6ff;
  --good: #047857;
  --bad: #b91c1c;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  font-family: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #d5dee8; color: var(--ink); }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.noscript { padding: 24px; }

.mi {
  font-family: "Material Symbols Outlined";
  font-weight: 500;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.num, .balance, .copybox input, .word b, input.num, .choice .fee {
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.app {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #f0f9ff 0%, var(--bg) 42%, #f3f4f6 100%);
}

.top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 60px;
  margin: 0;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; }
.brand-text { display: grid; gap: 2px; min-width: 0; }
.brand-text strong { font-size: 16px; line-height: 1.15; }
.brand-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
.logo { width: 36px; height: 36px; border-radius: 0; display: block; object-fit: cover; flex: none; }
.host { color: var(--muted); font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: 11px; font-weight: 700; line-height: 1.3;
  color: var(--muted); background: #f1f5f9; padding: 2px 7px;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.pill.on { color: var(--good); background: #ecfdf5; }
.pill.on::before { background: #10b981; }
.pill.wait { color: #92400e; background: #fffbeb; }
.pill.wait::before { background: #f59e0b; }
.top-actions { display: flex; gap: 4px; flex: none; }
button.icon-btn {
  width: 40px; height: 40px; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 0; background: #fff;
  display: grid; place-items: center;
}
button.icon-btn .mi { font-size: 20px; }
.screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom, 0px));
}
.app:has(.tabbar) .screen { padding-bottom: 16px; }
.tabbar {
  flex: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 2px 2px calc(2px + env(safe-area-inset-bottom, 0px));
}
.tabbar .tab {
  margin: 0;
  min-height: 54px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
}
.tabbar .tab .mi { font-size: 22px; }
.tabbar .tab.active { color: var(--accent); background: var(--accent-soft); }
button.icon-btn:focus-visible, .tabbar .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
h1 {
  display: flex; align-items: center; gap: 8px;
  font-size: 22px; line-height: 1.15; margin: 2px 0 10px;
}
h1 .mi { font-size: 22px; color: var(--accent); }
p { line-height: 1.45; }
.lead { color: var(--muted); margin-top: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 14px 0;
}
.card.flat { box-shadow: none; padding: 10px; }
.balance { font-size: 40px; font-weight: 700; letter-spacing: -0.04em; margin: 4px 0 0; text-align: center; }
.balance span { font-family: "Inter", system-ui, sans-serif; font-size: 18px; letter-spacing: 0; }
.sub { color: var(--muted); margin: 2px 0 12px; text-align: center; }

.qr-frame {
  width: 196px;
  margin: 4px auto 8px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
}
.qr-frame svg { width: 100%; height: auto; display: block; }

.copybox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 4px 4px 4px 12px;
}
.copybox input {
  border: 0;
  background: transparent;
  min-height: 42px;
  padding: 8px 0;
  width: 100%;
  min-width: 0;
  font-size: 12px;
  outline: none;
}
button.copy {
  width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
button.copy .mi { font-size: 22px; }

.row { display: flex; gap: 8px; min-width: 0; }
.row > * { flex: 1; min-width: 0; }
.stack { display: grid; gap: 10px; margin-top: 10px; min-width: 0; }
.stack > * { min-width: 0; max-width: 100%; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }

button.primary, button.ghost, button.danger, button.choice, a.ghost {
  margin-top: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 0; min-height: 48px; padding: 10px 14px; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.ghost, a.ghost { background: #fff; border-color: var(--line); color: inherit; text-decoration: none; }
button.danger { background: #fff; color: var(--bad); border-color: #fecaca; }
button.choice { background: #fff; border-color: var(--line); text-align: left; justify-content: flex-start; min-width: 0; padding: 10px 8px; }
button.choice strong { display: block; font-family: "Inter", system-ui, sans-serif; }
button.choice .fee { color: var(--muted); font-size: 11px; }
button.choice.active { border-color: var(--accent); background: var(--accent-soft); }
.fee-custom { display: grid; gap: 8px; margin-top: 8px; padding: 12px; border: 1px solid var(--line); background: #fff; }
.fee-custom.active { border-color: var(--accent); background: var(--accent-soft); }
.fee-custom-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 700; }
.fee-custom .hint { font-size: 13px; }
input.fee-range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer; }
input.fee-range:focus { outline: none; }
input.fee-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input.fee-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--accent) var(--fill, 0%), #e2e8f0 var(--fill, 0%)); }
input.fee-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28); }
input.fee-range::-moz-range-track { height: 6px; border: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent) var(--fill, 0%), #e2e8f0 var(--fill, 0%)); }
input.fee-range::-moz-range-thumb { width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28); }
.modes { display: grid; gap: 8px; margin-top: 4px; }
button.mode {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 12px;
  margin: 0;
  min-height: 68px;
  padding: 10px 14px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}
button.mode:hover { border-color: #93c5fd; }
button.mode .mode-icon {
  width: 44px;
  height: 44px;
  border-radius: 0;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent);
}
button.mode .mode-copy { display: grid; gap: 2px; min-width: 0; }
button.mode .mode-copy strong { display: block; font-size: 17px; line-height: 1.15; }
button.mode .mode-copy span { color: var(--muted); font-weight: 400; font-size: 14px; line-height: 1.25; }
button.mode .mode-check { color: transparent; font-size: 22px; justify-self: end; }
button.mode.active { border-color: var(--accent); background: var(--accent-soft); }
button.mode.active .mode-icon { background: var(--accent); color: var(--accent-ink); }
button.mode.active .mode-check { color: var(--accent); }
.chains { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-width: 0; }
.chains > button { min-width: 0; }
button.chain {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}
button.chain > span { display: grid; min-width: 0; }
button.chain strong { font-size: 15px; line-height: 1.15; }
button.chain .num { font-size: 14px; }
button.chain.active { border-color: var(--accent); background: var(--accent-soft); }
button.chain:disabled { opacity: 1; cursor: default; }
button:disabled { opacity: 0.55; cursor: default; }
button.link {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  background: none; border: 0; padding: 0; min-height: 0;
  color: #1e40af; font-weight: 700; white-space: nowrap;
}
button.link .mi { font-size: 18px; }

label { display: grid; gap: 6px; font-size: 15px; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 0;
  padding: 12px; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
input.num { font-size: 18px; }
.copybox input.num { font-size: 12px; }
.hint { color: var(--muted); font-weight: 400; font-size: 14px; }
.hint a { color: #1e40af; }
label.switch {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  column-gap: 12px;
  align-items: center;
  font-weight: 400;
  cursor: pointer;
}
label.switch input {
  position: absolute;
  z-index: 1;
  width: 52px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
label.switch .track {
  width: 52px;
  height: 32px;
  border-radius: 0;
  background: #e2e8f0;
  border: 1px solid var(--line);
  position: relative;
  pointer-events: none;
  transition: background 160ms ease, border-color 160ms ease;
}
label.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
  transition: transform 160ms ease;
}
label.switch input:checked + .track { background: var(--accent); border-color: #1e40af; }
label.switch input:checked + .track::after { transform: translateX(20px); }
label.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 3px; }

.words { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.word { background: #fff; border: 1px solid var(--line); border-radius: 0; padding: 8px 10px; }
.word b { color: #1e40af; font-weight: 700; margin-right: 6px; }

.banner { display: flex; gap: 8px; align-items: flex-start; border-radius: 0; padding: 10px 12px; margin: 10px 0; background: var(--accent-soft); }
.banner.bad { background: #fef2f2; color: var(--bad); }
.banner.good { background: #ecfdf5; color: var(--good); }
.nav { display: flex; gap: 8px; margin-top: 8px; }
.nav button { flex: 1; }
.list { display: grid; gap: 8px; }
.tx { display: flex; justify-content: space-between; gap: 12px; text-decoration: none; color: inherit; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx strong { font-family: "Roboto Mono", ui-monospace, monospace; }
.foot { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.foot a { color: inherit; }
.top .ghost { min-height: 40px; padding: 6px 10px; }

@media (max-width: 380px) {
  .row { flex-direction: column; }
  button.choice { width: 100%; }
}
@media (max-height: 700px) {
  .qr-frame { width: 148px; padding: 8px; }
  .balance { font-size: 32px; }
}
@media (min-width: 701px) {
  html:not(.is-embed) body { display: grid; place-items: center; background: #d5dee8; }
  html:not(.is-embed) .app {
    width: min(420px, calc(100vw - 48px));
    height: min(760px, calc(100dvh - 48px));
    border-radius: 32px;
    box-shadow: 0 0 0 10px #111827, 0 28px 70px rgba(15, 23, 42, 0.35);
  }
}
html.is-embed, html.is-embed body { background: #f9fafb; }
html.is-embed .app { width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
