/* Mini App 样式。颜色在 :root 里改（--primary 为主题色），深色模式在 [data-theme=dark] 里改 */

:root {
  --bg: #f5f3fa;
  --card: #ffffff;
  --text: #1d1a29;
  --muted: #6c6880;
  --border: #e6e2f0;
  --field: #f7f5fc;
  --primary: #7c3aed;
  --primary-strong: #6d28d9;
  --primary-soft: #f1ebff;
  --on-primary: #ffffff;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --ok-border: #bbf0cf;
  --warn: #b45309;
  --warn-soft: #fff7e8;
  --warn-border: #f8dfb0;
  --error: #dc2626;
  --error-soft: #fef1f1;
  --error-border: #f9caca;
  --info-soft: #eef4ff;
  --info-border: #cddcfb;
  --shadow: 0 1px 2px rgba(40, 20, 80, 0.04), 0 4px 16px rgba(40, 20, 80, 0.06);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

:root[data-theme='dark'] {
  --bg: #121019;
  --card: #1c1927;
  --text: #ecebf3;
  --muted: #9b97ae;
  --border: #2d2939;
  --field: #24202f;
  --primary: #9b6bff;
  --primary-strong: #8a55ff;
  --primary-soft: #2a2141;
  --ok: #4ade80;
  --ok-soft: #13261b;
  --ok-border: #1f4a30;
  --warn: #fbbf24;
  --warn-soft: #2a2213;
  --warn-border: #4a3a17;
  --error: #f87171;
  --error-soft: #2c1517;
  --error-border: #4f2226;
  --info-soft: #172036;
  --info-border: #263a63;
  --shadow: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 0;
  min-height: 100vh;
}

.page.center {
  display: grid;
  place-items: center;
}

.empty {
  text-align: center;
  color: var(--muted);
}

/* 标签页 */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: sticky;
  top: 8px;
  z-index: 5;
  box-shadow: var(--shadow);
}

.tab {
  border: 0;
  background: transparent;
  padding: 9px 0;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* 头图 */
.hero {
  margin-top: 14px;
  padding: 22px 18px 20px;
  border-radius: var(--radius);
  color: #fff;
  text-align: center;
  background: radial-gradient(120% 140% at 100% 0%, #a78bfa 0%, transparent 55%), linear-gradient(135deg, #7c3aed, #5b21b6);
  box-shadow: 0 8px 24px rgba(91, 33, 182, 0.25);
}

.hero-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fde68a;
}

.hero h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0.5px;
}

.hero p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

/* 状态条 */
.status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--muted);
}

.status b {
  font-weight: 600;
}
.status-ok b {
  color: var(--ok);
}
.status-warn b {
  color: var(--warn);
}
.status-muted b {
  color: var(--primary);
}

/* 卡片 */
.card {
  margin-top: 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
}

.label {
  display: block;
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.card .label:first-of-type {
  margin-top: 0;
}

.desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13.5px;
}

.desc b {
  color: var(--text);
}

/* 输入框 */
.field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 6px 0 14px;
  border-radius: 12px;
  background: var(--field);
  border: 1.5px solid transparent;
  transition: border-color 0.15s;
}

.field:focus-within {
  border-color: var(--primary);
  background: var(--card);
}

.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 14px 0;
  font-size: 14px;
}

.field input::placeholder,
.placeholder {
  color: var(--muted);
  opacity: 0.8;
  font-family: var(--font);
}

.field-static {
  justify-content: space-between;
}

.field-static .mono {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.field-static .addr-full {
  white-space: normal;
  word-break: break-all;
  font-size: 13px;
  padding: 10px 0;
}

.field-button {
  width: 100%;
  border: 1.5px dashed var(--border);
  justify-content: space-between;
  padding-right: 14px;
  cursor: pointer;
  text-align: left;
}

.field-disabled {
  opacity: 0.6;
}

.mono {
  font-family: var(--mono);
  letter-spacing: 0.2px;
}

.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* 提示 */
.hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 7px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
}

.hint .dot {
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--border);
}

.hint-ok .dot {
  background: var(--ok);
}
.hint-warn .dot {
  background: var(--warn);
}
.hint-error {
  color: var(--error);
}
.hint-error .dot {
  background: var(--error);
}
.hint b {
  color: var(--primary);
}

.estimate {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px dashed var(--border);
  background: var(--field);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.estimate b {
  font-size: 22px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid;
}

.notice-warn {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  color: var(--warn);
}
.notice-ok {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok);
}
.notice-error {
  background: var(--error-soft);
  border-color: var(--error-border);
  color: var(--error);
}
.notice-info {
  background: var(--info-soft);
  border-color: var(--info-border);
  color: var(--text);
}

.results {
  scroll-margin-bottom: 140px;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result b {
  font-size: 15px;
}

.result .muted {
  color: var(--muted);
  font-size: 12px;
}

.hash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--text);
}

.hash .mono {
  overflow: hidden;
  text-overflow: ellipsis;
}

.link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

/* 按钮 */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: var(--on-primary);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.28);
}

.btn-primary:disabled {
  box-shadow: none;
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-ghost {
  margin-top: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 14px;
}

.bottom-spacer {
  height: 130px;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.bottom-bar .btn-block {
  max-width: 528px;
  margin: 0 auto;
}

.bottom-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.bottom-hint.warn {
  color: var(--warn);
}

/* 个人中心 */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat + .stat {
  border-left: 1px solid var(--border);
}

.stat b {
  font-size: 26px;
  line-height: 1.2;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.stat b small {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.stat span {
  font-size: 12.5px;
  color: var(--muted);
}

.rules {
  margin: 14px 0 0;
  padding: 12px 14px 12px 30px;
  border-radius: 12px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
}

.rules li + li {
  margin-top: 4px;
}

.orders {
  list-style: none;
  margin: 0;
  padding: 0;
}

.orders li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.orders li + li {
  border-top: 1px solid var(--border);
}

.orders li > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.orders .muted {
  font-size: 12px;
  color: var(--muted);
}

.badge {
  flex: none;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-error {
  background: var(--error-soft);
  color: var(--error);
}
.badge-muted {
  background: var(--primary-soft);
  color: var(--primary);
}

/* 低价能量 */
.tiers {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tiers li {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--field);
}

.tiers li span:last-child {
  text-align: right;
}

.tiers b {
  color: var(--primary);
}

.page-end {
  height: calc(24px + env(safe-area-inset-bottom));
}

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 10, 30, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal {
  width: min(320px, 100%);
  padding: 26px 22px 22px;
  border-radius: 20px;
  background: var(--card);
  text-align: center;
}

.modal h3 {
  margin: 14px 0 4px;
  font-size: 17px;
}

.modal p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3.5px solid var(--primary-soft);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(20, 16, 32, 0.88);
  color: #fff;
  font-size: 13.5px;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2s;
  }
  .btn {
    transition: none;
  }
}

.strike {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: line-through;
}

.stat-row.two {
  grid-template-columns: repeat(2, 1fr);
}

.rules.plain {
  margin-top: 0;
}

.rules b {
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.result .row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
