:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --canvas: #0e1420;
  --surface: #192332;
  --raised: #212c3b;
  --border: #435268;
  --track: #2c394a;
  --text: #f5f7fb;
  --muted: #c0ccdb;
  --mint: #a1f1bd;
  --ink: #0e241a;
  --danger: #ffb7b4;
  --bottom: max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }
body { margin: 0; background: #090e17; color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .56; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--mint); outline-offset: 3px;
}
[hidden] { display: none !important; }
a { color: var(--mint); }

.shell { max-width: 540px; min-height: 100dvh; margin: 0 auto; background: var(--canvas); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; min-height: 64px;
  padding: max(10px, var(--tg-content-safe-area-inset-top, 0px)) 17px 10px;
  border-bottom: 1px solid var(--track);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 740; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: var(--mint); color: var(--ink); font-size: 25px; font-weight: 830;
}
.icon-button {
  display: inline-grid; place-items: center; width: 44px; height: 42px; padding: 0; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); font-size: 26px; line-height: 1;
}
#content { padding: 12px 15px calc(94px + var(--bottom)); }
h1 { font-size: clamp(26px, 7.6vw, 36px); line-height: 1.16; margin: 0 0 22px; letter-spacing: -.025em; }
h2 { font-size: 20px; margin: 27px 0 12px; line-height: 1.25; letter-spacing: -.015em; }
h3 { font-size: 18px; margin: 0; }
p { line-height: 1.45; }
.hint, .meta { font-size: 14px; color: var(--muted); }
.hint { margin: 10px 0; }
.empty { color: var(--muted); text-wrap: pretty; }
.summary {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 0;
  padding: 23px 16px; border: 1px solid #2c5760; border-radius: 13px;
  background: linear-gradient(135deg, #18383f, #122c32);
}
.summary .metric + .metric { border-inline-start: 1px solid #50717b; padding-inline-start: 14px; }
.metric { min-width: 0; }
.metric-label { display: block; margin-bottom: 8px; font-size: 15px; line-height: 1.2; }
.metric-value {
  display: block; overflow-wrap: anywhere; color: var(--mint); font-weight: 780;
  font-size: clamp(17px, 5.7vw, 31px); letter-spacing: -.035em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.copy-row {
  display: flex; gap: 7px; align-items: center; justify-content: space-between;
  min-height: 48px; padding: 0 6px 0 12px; border: 1px solid var(--border);
  border-radius: 11px; background: var(--surface); margin: 13px 0 6px;
}
.copy-value { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.wallet-address .copy-value { font: 600 clamp(8px, 2.5vw, 13px) ui-monospace, monospace; white-space: nowrap; }
.copy-button { background: transparent; border: 0; border-radius: 8px; width: 44px; height: 44px; flex: none; }
.copy-icon { display: inline-block; width: 12px; height: 14px; margin: 3px 4px 0 0; border: 1.5px solid currentColor; border-radius: 2px; position: relative; }
.copy-icon::before { position: absolute; content: ""; inset: -5px -6px 3px 3px; border: 1.5px solid currentColor; border-radius: 2px; border-inline-start-color: transparent; border-bottom-color: transparent; }
.chain-caption { margin: 0 0 19px; font-size: 13px; color: var(--muted); }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid #91a7c0;
  border-radius: 10px; padding: 8px 10px; background: var(--surface); font-weight: 670; line-height: 1.2; text-align: center;
}
.button:hover, .icon-button:hover { background: var(--raised); }
.button.primary { background: var(--mint); border-color: var(--mint); color: var(--ink); }
.button.primary:hover { background: #baf6cf; }
.button.quiet { border-color: var(--border); }
.button.danger { color: var(--danger); border-color: #7e5961; }
.button.full { width: 100%; }
.wallet-primary { min-height: 54px; font-size: 19px; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 11px; }
.segment {
  display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 4px;
  border: 1px solid #91a7c0; border-radius: 11px; background: var(--surface); margin-bottom: 16px;
}
.segment button { border: 0; border-radius: 7px; background: transparent; font-weight: 690; min-height: 42px; }
.segment button[aria-pressed="true"] { background: var(--mint); color: var(--ink); }
.panel {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 13px; margin-bottom: 14px;
}
.form-row {
  min-width: 0; display: grid; grid-template-columns: minmax(82px, 109px) minmax(0, 1fr); gap: 9px;
  align-items: center; margin-bottom: 10px;
}
.form-row input, .form-row select, .form-row textarea, .input {
  min-width: 0; width: 100%; min-height: 42px; padding: 8px 9px; border: 1px solid #64768d;
  border-radius: 9px; background: #131c2a; color: var(--text); font-size: 16px;
}
.form-row textarea { min-height: 76px; resize: vertical; }
.form-row input::placeholder, .form-row textarea::placeholder { color: #a1afc1; }
.toggle-row {
  display: flex; justify-content: space-between; gap: 12px; min-height: 44px;
  align-items: center; cursor: pointer; padding-block: 4px;
}
.toggle { appearance: none; flex: none; width: 43px; height: 25px; border: 1px solid #7c8da5; border-radius: 22px; position: relative; background: #273548; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #f2f8f6; }
.toggle:checked { background: #459267; }
.toggle:checked::after { transform: translateX(18px); }
.cards { display: grid; gap: 12px; }
.card { margin: 0; overflow: hidden; }
.card-head { display: flex; align-items: start; gap: 8px; justify-content: space-between; }
.card-status { display: inline-block; background: #a1f1bd; color: var(--ink); padding: 3px 8px; font-size: 12px; font-weight: 760; border-radius: 8px; }
.card p { margin: 7px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.card-tools { display: flex; flex-wrap: wrap; gap: 3px 13px; margin-top: 8px; }
.text-button { border: 0; background: transparent; color: var(--mint); padding: 5px 0; min-height: 35px; text-align: start; font-weight: 600; }
.text-button.danger { color: var(--danger); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 19px; }
.stats .panel { margin: 0; }
.field-name { display: block; margin: 15px 0 -5px; font-weight: 630; }
.settings { margin-top: 19px; }
.ledger { border: 1px solid var(--border); border-radius: 11px; margin: 0; padding: 0; list-style: none; background: var(--surface); }
.ledger > li + li { border-top: 1px solid var(--border); }
.ledger-item { padding: 11px 13px 10px; }
.ledger-line { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 9px; align-items: center; }
.ledger-icon { color: var(--mint); font-size: 25px; text-align: center; }
.ledger-title { font-size: 15px; font-weight: 700; }
.ledger-meta { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.ledger-amount { text-align: end; font-weight: 730; font-size: 15px; overflow-wrap: anywhere; max-width: 130px; }
.identifier { overflow-wrap: anywhere; font: 12px ui-monospace, monospace; }
.positive { color: var(--mint); }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding-block: 8px; align-items: baseline; }
.detail-row + .detail-row { border-top: 1px solid var(--track); }
.detail-row strong { text-align: end; overflow-wrap: anywhere; }
.dialog-content h2 { margin: 0 0 15px; }
.dialog-content .summary-values { margin: 10px 0 17px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.dialog-header h2 { margin: 0; }
.dialog-error { color: var(--danger); }
.dialog-error:empty { display: none; }
#dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 15px 16px;
  border-radius: 15px; width: min(100% - 24px, 480px); max-height: calc(100dvh - 30px); overflow: auto;
}
#dialog::backdrop { background: #050a13ab; }
.close-button { font-size: 23px; }
.navigation {
  position: fixed; z-index: 2; inset: auto 0 0; width: min(100%, 540px); margin-inline: auto;
  background: var(--canvas); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 8px 3px calc(8px + var(--bottom)); border: 1px solid var(--border); border-bottom: 0; border-radius: 15px 15px 0 0;
}
.navigation button {
  border: 0; background: transparent; min-height: 49px; min-width: 0; border-radius: 9px;
  font-size: clamp(10px, 3.2vw, 14px); display: grid; place-content: center; justify-items: center; gap: 4px; padding: 0 2px;
}
.nav-icon {
  display: grid; place-items: center; width: 24px; height: 24px; position: relative;
}
.nav-icon::before, .nav-icon::after { content: ""; position: absolute; }
.wallet-icon::before { inset: 4px 1px 2px; border: 2px solid currentColor; border-radius: 5px; }
.wallet-icon::after { width: 9px; height: 6px; right: 0; top: 10px; background: var(--canvas); border: 2px solid currentColor; border-radius: 4px; }
.gift-icon::before {
  width: 16px; height: 12px; left: 4px; top: 10px; border: 2px solid currentColor; border-radius: 2px;
  background: linear-gradient(90deg, transparent 44%, currentColor 44% 56%, transparent 56%);
}
.gift-icon::after { height: 5px; width: 20px; left: 2px; top: 7px; border: 2px solid currentColor; border-radius: 2px; }
.referral-icon::before { width: 6px; height: 6px; border: 2px solid currentColor; border-radius: 50%; top: 1px; left: 4px; }
.referral-icon::after { width: 11px; height: 7px; border: 2px solid currentColor; border-bottom: 0; border-radius: 7px 7px 0 0; left: 1px; top: 13px; }
.referral-icon i {
  position: absolute; border: 2px solid currentColor; border-bottom: 0; width: 6px; height: 7px;
  right: 1px; top: 13px; border-left: 0; border-radius: 0 6px 0 0;
}
.referral-icon i::before {
  content: ""; width: 4px; height: 5px; position: absolute; right: 0; top: -12px;
  border: 2px solid currentColor; border-left: 0; border-radius: 0 8px 8px 0;
}
.history-icon::before { border-radius: 50%; inset: 1px; border: 2px solid currentColor; }
.history-icon::after { top: 5px; left: 11px; width: 5px; height: 7px; border: solid currentColor; border-width: 0 0 2px 2px; border-radius: 0 0 0 2px; }
.navigation button[aria-current="page"] { color: var(--mint); font-weight: 730; }
.notices {
  position: fixed; z-index: 4; bottom: calc(76px + var(--bottom)); left: 50%; translate: -50%;
  max-width: min(520px, calc(100% - 22px)); width: max-content; pointer-events: none;
}
.notices:not(:empty) { padding: 11px 13px; border-radius: 10px; background: var(--raised); border: 1px solid var(--border); box-shadow: 0 4px 15px #070b14b8; }
.notices.error:not(:empty) { background: #39252d; border-color: #a3636b; }

@media (min-width: 460px) {
  .topbar { min-height: 74px; }
  #content { padding: 18px 17px calc(103px + var(--bottom)); }
  .summary { padding-block: 27px; }
  .metric-value { font-size: 34px; }
  .copy-row { min-height: 51px; }
  .wallet-primary { min-height: 58px; }
  .navigation button { min-height: 58px; }
}
