:root {
  --page-bg: #eef2f7;
  --card: #ffffff;
  --blue-50: #e8f0fe;
  --blue-100: #d2e3fc;
  --blue-600: #1a73e8;
  --blue-700: #1557b0;
  --text: #202124;
  --muted: #5f6368;
  --green: #137333;
  --border: #dadce0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(60,64,67,.15), 0 4px 24px rgba(60,64,67,.08);
  --content-max: 560px;
  --nav-max: 720px;
  --touch-min: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body.rent-page {
  font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: var(--safe-bottom);
}

/* 顶栏 */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(238, 242, 247, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(218, 220, 224, 0.6);
  padding-top: var(--safe-top);
}
.top-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  max-width: var(--nav-max);
  margin: 0 auto;
}
.nav-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}
.nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-user { gap: 6px; }
.nav-user-name {
  font-size: 13px;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-bal {
  color: var(--blue-600);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.nav-btn {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.nav-btn-primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}
.nav-btn-ghost {
  background: transparent;
}
@media (hover: hover) {
  .nav-btn:hover { opacity: 0.88; }
}

.page-center {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 12px 16px calc(32px + var(--safe-bottom));
}

/* 主卡片 */
.rent-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 0;
  gap: 12px;
}
.card-top-left { display: flex; flex-direction: column; gap: 6px; }
.rent-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue-600);
  background: var(--blue-50);
  padding: 3px 10px;
  border-radius: 6px;
  width: fit-content;
}
.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card-tabs {
  display: flex;
  gap: 16px;
  padding-top: 8px;
}
.card-tab {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 4px 10px;
  min-height: var(--touch-min);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  border-bottom: 2px solid transparent;
}
.card-tab.active {
  color: var(--blue-600);
  font-weight: 600;
  border-bottom-color: var(--blue-600);
}

.card-body { padding: 16px 24px 24px; }

/* 模式切换 */
.mode-switch {
  display: flex;
  background: var(--blue-50);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.mode-opt {
  flex: 1;
  min-height: var(--touch-min);
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.mode-opt.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* 步进器 + 能量 */
.counter-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.stepper {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.step-btn {
  width: var(--touch-min);
  min-height: var(--touch-min);
  height: var(--touch-min);
  border: none;
  background: var(--card);
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
@media (hover: hover) {
  .step-btn:hover { background: var(--blue-50); }
}
.step-input {
  width: 52px;
  min-height: var(--touch-min);
  height: var(--touch-min);
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
}
.energy-pill {
  flex: 1;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.energy-pill.full { width: 100%; margin-top: 10px; }
.energy-pill-label { color: var(--muted); margin-right: 4px; }
.energy-pill-val { font-weight: 700; color: var(--blue-700); }

.energy-chips-row { display: flex; gap: 8px; margin-bottom: 10px; }
.eq-chip {
  padding: 8px 18px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.eq-chip.active {
  border-color: var(--blue-600);
  color: var(--blue-600);
  background: var(--blue-50);
}
.eq-chip.disabled, .qnum.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 快捷数量 */
.quick-nums {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.qnum {
  flex: 1;
  min-width: 0;
  min-height: var(--touch-min);
  height: var(--touch-min);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.qnum.active {
  border-color: var(--blue-600);
  color: var(--blue-600);
  background: var(--blue-50);
}

/* 价格区 */
.price-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
  gap: 12px;
}
.price-panel.compact { margin-top: 16px; }
.price-left { font-size: 12px; }
.burn-ref { color: var(--green); font-weight: 500; }
.burn-ref .muted { color: var(--muted); font-weight: 400; }
.price-right { text-align: right; }
.price-right.full { width: 100%; text-align: center; }
.price-trx {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.price-usd { font-size: 13px; color: var(--muted); margin-top: 2px; }
.price-sun { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 付款条 */
.pay-banner {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-all;
}
.pay-banner-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue-700);
  background: #fff;
  border-radius: 6px;
  vertical-align: middle;
}
.fld-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
  line-height: 1.5;
}
.btn-modal-copy {
  margin-top: 8px;
  width: 100%;
}
.pay-addr-link {
  color: var(--blue-600);
  font-weight: 500;
  text-decoration: underline;
  display: inline;
  word-break: break-all;
}
.pay-addr-link:hover { color: var(--blue-700); }
.btn-copy-inline {
  margin-left: 8px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
}

/* 二维码 */
.qr-row {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  background: #fafbfc;
}
.qr-box {
  flex-shrink: 0;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.qr-box img {
  display: block;
  width: 140px;
  height: 140px;
}
.qr-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.qr-desc-line {
  display: inline;
}
@media (min-width: 600px) {
  .qr-desc-line {
    display: block;
  }
  .qr-desc-line + .qr-desc-line {
    margin-top: 6px;
  }
}
.qr-desc strong { color: var(--blue-600); }

/* 底部提示 */
.tip-box {
  background: var(--blue-50);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.tip-box a { color: var(--blue-600); }

.balance-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.fld-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.fld-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  font-family: inherit;
}
.btn-pay {
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
}
.btn-pay:hover { background: var(--blue-700); }

.order-toast {
  margin-top: 16px;
  padding: 12px 16px;
  background: #e6f4ea;
  border: 1px solid #ceead6;
  border-radius: 8px;
  font-size: 13px;
}

.mono { font-family: ui-monospace, "SF Mono", monospace; }
.hidden { display: none !important; }

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding-bottom: var(--safe-bottom);
  -webkit-overflow-scrolling: touch;
}
.modal-wide { max-width: 480px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-x {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
}
.modal-body { padding: 20px; }
.modal-body input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}
.modal-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.mtab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8f9fa;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.mtab.active {
  border-color: var(--blue-600);
  background: var(--blue-50);
  color: var(--blue-600);
  font-weight: 600;
}
.btn-modal {
  width: 100%;
  padding: 12px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.modal-hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.mini-tbl { width: 100%; font-size: 12px; margin-top: 12px; }
.mini-tbl th, .mini-tbl td { padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: left; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  top: auto;
  z-index: 300;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  background: #323232;
  color: #fff;
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}
.toast.error { background: #b3261e; }
.toast.success { background: var(--green); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ok { background: #e6f4ea; color: var(--green); }
.badge-pending { background: #fef7e0; color: #b06000; }
.badge-fail { background: #fce8e6; color: #c5221f; }

/* ========== 平板 / 小屏 PC ========== */
@media (min-width: 600px) {
  .top-nav-inner {
    padding: 12px 24px;
  }
  .page-center {
    padding: 16px 24px 56px;
  }
  .card-body {
    padding: 20px 28px 28px;
  }
  .card-top {
    padding: 24px 28px 0;
  }
  .nav-user-name {
    max-width: 120px;
  }
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
  .modal {
    border-radius: 14px;
    max-height: 90vh;
  }
  .toast {
    left: auto;
    right: 24px;
    bottom: auto;
    top: calc(16px + var(--safe-top));
    text-align: left;
  }
}

/* ========== PC 宽屏 ========== */
@media (min-width: 900px) {
  :root {
    --content-max: 580px;
  }
  .card-title {
    font-size: 1.5rem;
  }
  .price-trx {
    font-size: 2rem;
  }
  .qr-box img {
    width: 160px;
    height: 160px;
  }
  .counter-block {
    gap: 16px;
  }
  .quick-nums {
    gap: 10px;
  }
  .qnum {
    max-width: none;
  }
}

/* ========== H5：一屏自适应、无页面滚动条 ========== */
@media (max-width: 599px) {
  html, body.rent-page {
    height: 100%;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: fixed;
    inset: 0;
  }

  body.rent-page {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
    font-size: clamp(11px, 2.8vmin, 14px);
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  .top-nav {
    flex-shrink: 0;
    position: relative;
  }
  .top-nav-inner {
    padding: clamp(6px, 1.5vh, 10px) 12px;
  }
  .nav-brand { font-size: clamp(12px, 3.2vmin, 14px); }
  .nav-btn {
    padding: 6px 10px;
    font-size: clamp(11px, 2.8vmin, 12px);
    min-height: clamp(32px, 8vmin, 40px);
  }
  .nav-user-name { display: none; }

  .page-center {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(4px, 1vh, 8px) clamp(8px, 2vw, 12px) 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .rent-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: clamp(10px, 2.5vmin, 14px);
    box-shadow: 0 2px 12px rgba(60,64,67,.1);
  }

  .card-top {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: clamp(8px, 2vh, 12px) clamp(10px, 2.5vw, 14px) 0;
    gap: 8px;
    border-bottom: 1px solid var(--border);
  }
  .card-top-left {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .rent-badge {
    font-size: clamp(9px, 2.2vmin, 11px);
    padding: 2px 6px;
  }
  .card-title {
    font-size: clamp(14px, 4vmin, 18px);
    margin: 0;
  }
  .card-tabs {
    padding: 0;
    border: none;
    gap: clamp(12px, 3vw, 18px);
  }
  .card-tab {
    padding: 4px 0 6px;
    min-height: auto;
    font-size: clamp(12px, 3vmin, 14px);
  }

  .card-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: clamp(6px, 1.5vh, 10px) clamp(10px, 2.5vw, 12px) clamp(8px, 1.5vh, 10px);
  }

  #panelDirect {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: clamp(4px, 1vh, 8px);
  }

  #panelBalance {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mode-switch {
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 3px;
  }
  .mode-opt {
    padding: clamp(6px, 1.5vh, 8px) 4px;
    min-height: clamp(32px, 8vmin, 38px);
    font-size: clamp(11px, 2.8vmin, 12px);
  }

  .counter-block {
    flex-shrink: 0;
    flex-direction: row;
    align-items: stretch;
    gap: clamp(6px, 1.5vw, 8px);
    margin-bottom: 0;
  }
  .stepper { flex: 0 0 auto; }
  .step-btn {
    width: clamp(36px, 10vmin, 44px);
    min-height: clamp(36px, 10vmin, 44px);
    height: clamp(36px, 10vmin, 44px);
    font-size: clamp(16px, 4vmin, 20px);
  }
  .step-input {
    width: clamp(40px, 11vmin, 48px);
    min-height: clamp(36px, 10vmin, 44px);
    height: clamp(36px, 10vmin, 44px);
    font-size: clamp(14px, 3.5vmin, 16px);
  }
  .energy-pill {
    flex: 1;
    min-width: 0;
    padding: clamp(6px, 1.5vh, 8px);
    font-size: clamp(11px, 2.8vmin, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .quick-nums {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(4px, 1vw, 6px);
    margin-bottom: 0;
  }
  .qnum {
    min-height: clamp(32px, 8vmin, 38px);
    height: clamp(32px, 8vmin, 38px);
    font-size: clamp(12px, 3vmin, 14px);
  }

  .price-panel {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    margin-bottom: 0;
    gap: 8px;
  }
  .price-left {
    flex: 1;
    min-width: 0;
    font-size: clamp(9px, 2.4vmin, 11px);
  }
  .burn-ref .muted { display: none; }
  .price-right {
    flex-shrink: 0;
    text-align: right;
    padding: 0;
    background: none;
    border: none;
  }
  .price-trx {
    font-size: clamp(16px, 4.5vmin, 20px);
    line-height: 1.1;
  }
  .price-usd, .price-sun {
    font-size: clamp(9px, 2.4vmin, 10px);
    margin-top: 0;
  }

  .pay-banner {
    flex-shrink: 0;
    margin-bottom: 0;
    padding: clamp(8px, 2vh, 10px);
    font-size: clamp(10px, 2.6vmin, 12px);
    line-height: 1.45;
  }
  .pay-banner .btn-copy-inline {
    display: inline-block;
    width: auto;
    margin: 0 0 0 6px;
    min-height: clamp(28px, 7vmin, 32px);
    padding: 4px 10px;
    vertical-align: middle;
  }
  .pay-addr-link {
    display: inline;
    font-size: clamp(9px, 2.4vmin, 11px);
    word-break: break-all;
  }

  .qr-row {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 0;
  }
  .qr-box {
    flex-shrink: 0;
    padding: 3px;
    line-height: 0;
    align-self: flex-start;
  }
  .qr-box img {
    width: clamp(72px, 24vw, 92px);
    height: clamp(72px, 24vw, 92px);
    object-fit: contain;
    vertical-align: top;
  }
  .qr-desc {
    flex: 1;
    min-width: 0;
    align-self: center;
    margin: 0;
    padding: 0;
    font-size: clamp(10px, 2.6vmin, 12px);
    line-height: 1.45;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }
  .qr-desc-line {
    display: block;
  }

  .tip-box-pc { display: none; }
  .memo-link {
    flex-shrink: 0;
    display: block;
    width: 100%;
    color: var(--blue-600);
    font-size: clamp(9px, 2.4vmin, 10px);
    text-align: center;
    padding: 2px 0 0;
    text-decoration: underline;
  }

  .order-toast {
    flex-shrink: 0;
    margin-top: 4px;
    padding: 6px 10px;
    font-size: clamp(10px, 2.5vmin, 11px);
  }

  .eq-chip {
    min-height: clamp(34px, 8vmin, 40px);
  }

  .fld-input,
  .modal-body input {
    font-size: 16px;
  }

  /* 缩放容器：极短屏由 JS 写入 transform */
  .page-center.is-scaled {
    overflow: hidden;
  }
  .rent-card.is-scaled {
    transform-origin: top center;
    will-change: transform;
  }
}

@media (max-width: 599px) and (max-height: 640px) {
  .burn-ref { display: none; }
  .price-usd { display: none; }
}

@media (max-width: 599px) and (max-height: 560px) {
  .price-sun { display: none; }
  .memo-link { padding: 0; }
}

@media (max-width: 360px) {
  .nav-btn { padding: 6px 8px; }
  .card-top-left { gap: 4px; }
}

/* H5 横屏：仍保持一屏，横向排布 */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 500px) {
  .qr-row {
    flex-direction: row;
    align-items: flex-start;
    padding: 6px 10px;
  }
  .counter-block { flex-direction: row; }
  .qr-box img {
    width: clamp(56px, 16vh, 80px);
    height: clamp(56px, 16vh, 80px);
  }
  .qr-desc { align-self: center; }
  .modal { max-height: 95dvh; }
}
