:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f10;
  --surface: #181c1f;
  --surface-strong: #20262a;
  --input-bg: #121516;
  --ink: #f3f5f7;
  --muted: #9da7ad;
  --line: #343b40;
  --gold: #f2c94c;
  --green: #35d084;
  --blue: #77b7ff;
  --red: #ef6b73;
  --brand-bg: #f2c94c;
  --brand-ink: #17120a;
  --primary-ink: #17120a;
  --active-bg: #f2c94c;
  --active-ink: #17120a;
  --toast-bg: #f3f5f7;
  --toast-ink: #0d0f10;
  --warning-bg: rgba(242, 201, 76, 0.12);
  --warning-ink: #f2c94c;
  --error-bg: rgba(239, 107, 115, 0.12);
  --secret-bg: #080a0b;
  --secret-ink: #f3f5f7;
  --qr-bg: #ffffff;
  --focus-ring: rgba(120, 169, 230, 0.24);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --page-bg:
    linear-gradient(180deg, rgba(18, 21, 22, 0.96), rgba(9, 10, 11, 1)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 72px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-strong: #eef1f3;
  --input-bg: #ffffff;
  --ink: #15181a;
  --muted: #66717a;
  --line: #d7dde2;
  --gold: #c7951b;
  --green: #168a5e;
  --blue: #256ca8;
  --red: #bf3340;
  --brand-bg: #f2c94c;
  --brand-ink: #17120a;
  --primary-ink: #17120a;
  --active-bg: #15181a;
  --active-ink: #ffffff;
  --toast-bg: #15181a;
  --toast-ink: #ffffff;
  --warning-bg: #fff7dd;
  --warning-ink: #7a5a05;
  --error-bg: #fff0f1;
  --secret-bg: #0d0f10;
  --secret-ink: #f3f5f7;
  --qr-bg: #ffffff;
  --focus-ring: rgba(119, 183, 255, 0.22);
  --shadow: 0 18px 50px rgba(13, 15, 16, 0.1);
  --page-bg:
    linear-gradient(180deg, #f4f5f6, #ffffff),
    repeating-linear-gradient(90deg, rgba(13, 15, 16, 0.025) 0, rgba(13, 15, 16, 0.025) 1px, transparent 1px, transparent 72px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

select {
  min-height: 46px;
}

select + label {
  margin-top: 16px;
}

label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  display: block;
  flex: 0 0 46px;
  object-fit: contain;
}

.brand h1,
.brand-title,
.brand p,
h2,
h3,
p {
  margin: 0;
}

.brand h1,
.brand-title {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 800;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.api-state {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
}

.api-state.ok .state-dot {
  background: var(--green);
}

.top-wallet-switch {
  min-height: 38px;
  max-width: min(360px, 34vw);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 4px 6px 4px 10px;
}

.top-wallet-switch label {
  margin: 0;
  white-space: nowrap;
}

.top-wallet-switch select {
  min-height: 30px;
  min-width: 160px;
  border: 0;
  background: var(--surface-strong);
  padding: 6px 8px;
}

.api-state.error .state-dot {
  background: var(--red);
}

.screen {
  display: block;
}

.screen.narrow {
  max-width: 720px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

.hero-panel,
.panel,
.wallet-summary,
.wallet-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 30px;
}

.hero-panel h2 {
  margin-top: 8px;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-panel p:not(.eyebrow) {
  max-width: 720px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.security-list {
  display: grid;
  gap: 8px;
}

.security-list span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px 12px;
  color: var(--green);
  white-space: nowrap;
  font-weight: 800;
  font-size: 13px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 22px;
}

.panel h2 {
  font-size: 24px;
  line-height: 1.2;
}

.panel h3 {
  font-size: 20px;
  line-height: 1.2;
}

.panel p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  border: 1px solid rgba(242, 201, 76, 0.48);
  background: linear-gradient(90deg, #f2c94c, #d9ae3f);
  color: var(--primary-ink);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.danger-button {
  background: var(--red);
  color: #fff;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.theme-toggle {
  min-width: 64px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.setup-grid .primary-button,
.setup-grid .secondary-button {
  margin-top: 20px;
  width: 100%;
}

.panel-link {
  margin-top: 20px;
  width: 100%;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.warning-text {
  border: 1px solid rgba(201, 141, 34, 0.32);
  background: var(--warning-bg);
  color: var(--warning-ink);
  border-radius: 8px;
  padding: 12px;
  margin: 0 0 14px !important;
}

.notice {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
}

.notice-error {
  border-color: rgba(183, 45, 59, 0.34);
  background: var(--error-bg);
  color: var(--red);
  margin-bottom: 14px;
}

.mnemonic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.mnemonic-grid li {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.mnemonic-grid span {
  color: var(--muted);
  font-size: 12px;
}

.mnemonic-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.derived-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 14px;
  margin-top: 16px;
  overflow-wrap: anywhere;
}

.derived-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.split-fields,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.form-field {
  margin-top: 16px;
}

.form-grid {
  grid-template-columns: minmax(240px, 2fr) minmax(160px, 1fr) minmax(120px, 0.5fr) auto;
  align-items: end;
}

.wallet-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  margin-bottom: 14px;
}

.send-max-wrap {
  display: flex;
  align-items: end;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.recovery-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.recovery-notice {
  margin-top: 14px;
}

.error-text,
.success-text {
  min-height: 20px;
  margin-top: 12px !important;
  font-size: 14px;
}

.error-text {
  color: var(--red) !important;
}

.success-text {
  color: var(--green) !important;
}

.wallet-summary {
  display: grid;
  grid-template-columns: minmax(210px, 0.75fr) minmax(0, 1.4fr) auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.balance-value {
  margin-top: 8px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.muted-line {
  margin-top: 8px;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.address-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 12px;
}

.address-card span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.address-card code,
#receiveAddress {
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary-actions {
  display: grid;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
}

.tab-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tab-button.active {
  background: var(--active-bg);
  color: var(--active-ink);
  border-color: var(--active-bg);
}

.wallet-panel {
  padding: 22px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.tx-preview {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 14px;
  margin-top: 16px;
}

.tx-preview dl,
.info-list {
  margin: 0;
}

.tx-preview div,
.info-list div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.tx-preview div:last-child,
.info-list div:last-child {
  border-bottom: 0;
}

.tx-preview dt,
.info-list dt {
  color: var(--muted);
  font-weight: 800;
}

.tx-preview dd,
.info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.receive-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.qr-box {
  width: 220px;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--qr-bg);
  border-radius: 8px;
  padding: 10px;
}

.receive-grid h2 {
  margin-bottom: 10px;
}

.receive-grid p {
  color: var(--muted);
  margin-bottom: 16px;
}

.receive-grid .secondary-button {
  margin-top: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 13px;
}

.history-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: start;
}

.history-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
}

.history-direction {
  color: var(--ink);
  font-weight: 900;
}

.history-amount {
  color: var(--green);
  font-weight: 900;
}

.history-amount.sent {
  color: var(--red);
}

.history-meta {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.history-details {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.history-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
}

.history-row dt {
  color: var(--muted);
  font-weight: 800;
}

.history-row dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.address-list {
  display: grid;
  gap: 4px;
}

.address-fold {
  min-width: 0;
}

.address-fold summary,
.address-list-fold summary {
  cursor: pointer;
  max-width: 100%;
}

.address-fold summary::marker,
.address-list-fold summary::marker {
  color: var(--muted);
}

.address-list-fold {
  min-width: 0;
}

.address-list-preview {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
}

.address-extra {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.address-fold .address-full {
  display: block;
  margin-top: 5px;
  max-width: 100%;
}

.address-list-full {
  margin-top: 6px;
}

.history-loading,
.history-error {
  color: var(--muted);
  font-size: 13px;
}

.history-error {
  color: var(--red);
}

.history-item code {
  overflow-wrap: anywhere;
}

.history-item > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.settings-grid h2,
.danger-zone h2 {
  margin-bottom: 12px;
}

.secret-box {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--secret-bg);
  color: var(--secret-ink);
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.danger-zone {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 18px;
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.site-footer a,
.static-page a.static-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover,
.static-page a.static-link:hover {
  text-decoration: underline;
}

.brand.static-link {
  color: var(--ink);
  text-decoration: none;
}

.static-page {
  max-width: 900px;
  margin: 0 auto;
}

.static-page article {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.static-page h1 {
  margin: 6px 0 14px;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

.static-page h2 {
  margin-top: 24px;
  font-size: 22px;
}

.static-page p,
.static-page li {
  color: var(--muted);
  line-height: 1.65;
}

.static-page p {
  margin-top: 12px;
}

.static-page ul {
  padding-left: 22px;
}

@media (max-width: 920px) {
  .hero-panel,
  .setup-grid,
  .wallet-summary,
  .metric-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .security-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px 0 14px;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(94px, 0.72fr) repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
  }

  .api-state {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding: 8px 10px;
  }

  .api-state span:last-child {
    white-space: nowrap;
  }

  .top-wallet-switch {
    grid-column: 2 / -1;
    max-width: none;
    width: 100%;
    min-width: 0;
    padding: 4px 6px 4px 8px;
  }

  .top-wallet-switch label {
    font-size: 12px;
  }

  .top-wallet-switch select {
    flex: 1;
    min-width: 0;
    width: 100%;
    font-size: 14px;
  }

  .top-actions .ghost-button,
  .top-actions .icon-button {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
  }

  .brand {
    width: 100%;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .hero-panel,
  .panel,
  .wallet-summary,
  .wallet-panel {
    padding: 14px;
  }

  .hero-panel h2 {
    font-size: 34px;
  }

  .security-list,
  .split-fields,
  .form-grid,
  .recovery-actions,
  .receive-grid {
    grid-template-columns: 1fr;
  }

  .wallet-summary {
    gap: 12px;
  }

  .balance-value {
    font-size: clamp(28px, 9vw, 38px);
  }

  .address-card {
    grid-template-columns: 1fr;
  }

  .address-card .ghost-button {
    width: 100%;
  }

  .summary-actions {
    grid-template-columns: 1fr;
  }

  .mnemonic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-box {
    width: 100%;
  }

  .tx-preview div,
  .info-list div,
  .history-main,
  .history-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
