:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e8eaed;
  --text: #1a1a1a;
  --text-secondary: #5f6368;
  --primary: #1a73e8;
  --sidebar-width: 300px;
  /* App 嵌入 + iOS 刘海屏安全区（需 viewport-fit=cover） */
  --app-safe-top: constant(safe-area-inset-top);
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: constant(safe-area-inset-bottom);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-left: constant(safe-area-inset-left);
  --app-safe-left: env(safe-area-inset-left, 0px);
  --app-safe-right: constant(safe-area-inset-right);
  --app-safe-right: env(safe-area-inset-right, 0px);
  --app-top-offset: 24px;
  --app-title-height: 44px;
  --header-height: var(--app-title-height);
  --app-chrome-top: calc(var(--app-safe-top) + var(--app-top-offset));
  --app-chrome-height: calc(var(--app-chrome-top) + var(--app-title-height));
  --app-layout-height: calc(
    100dvh - var(--app-chrome-height) - var(--app-safe-bottom)
  );
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  background: var(--bg);
}

body {
  min-height: 100%;
  min-height: -webkit-fill-available;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  position: fixed;
  top: var(--app-chrome-top);
  left: var(--app-safe-left);
  right: var(--app-safe-right);
  z-index: 100;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  height: var(--app-title-height);
  padding: 0 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

/* 刘海区 + App 顶栏留白区域同步白色，避免顶部露出灰底 */
.app-header::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--app-safe-left));
  right: calc(-1 * var(--app-safe-right));
  bottom: 100%;
  height: var(--app-chrome-top);
  background: #ffffff;
}

.app-header h1 {
  grid-column: 1 / -1;
  grid-row: 1;
  justify-self: center;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 96px);
  pointer-events: none;
}

.app-header .btn-back {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  z-index: 1;
  pointer-events: auto;
}

.app-header .btn-close {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  z-index: 1;
  pointer-events: auto;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon:active {
  background: var(--bg);
}

.btn-icon[hidden] {
  display: none;
}

.btn-back {
  display: none;
}

body.view-detail .btn-back {
  display: inline-flex;
}

.layout {
  display: flex;
  margin-top: var(--app-chrome-height);
  height: var(--app-layout-height);
  height: calc(
    100vh - var(--app-chrome-height) - var(--app-safe-bottom)
  );
  overflow: hidden;
}

/* App 自带顶栏时隐藏 H5 标题，仅保留 top 留白 */
body.embed-hide-title .app-header {
  display: none;
}

body.embed-hide-title .layout {
  margin-top: calc(var(--app-safe-top) + var(--app-top-offset));
  height: calc(
    100vh - var(--app-safe-top) - var(--app-top-offset) - var(--app-safe-bottom)
  );
  height: calc(
    100dvh - var(--app-safe-top) - var(--app-top-offset) - var(--app-safe-bottom)
  );
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--app-safe-bottom);
}

.sidebar-home-tip {
  padding: 14px 16px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  padding: 14px 16px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.bank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.bank-item:active {
  background: #f0f4ff;
}

.bank-item.is-active {
  background: #e8f0fe;
  color: var(--primary);
}

.bank-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  flex-shrink: 0;
}

.bank-item-name {
  flex: 1;
  min-width: 0;
}

.bank-item .chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.bank-item.is-active .chevron {
  color: var(--primary);
}

/* 银行操作详情（章节 + 步骤列表） */
.bank-detail-subtitle {
  margin-bottom: 16px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section-title {
  margin-bottom: 12px;
  padding-bottom: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.step-block {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step-block:last-child {
  margin-bottom: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  display: none;
}

.layout.view-detail .content {
  display: block;
}

.content-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(16px + var(--app-safe-bottom));
}

.content-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.content-placeholder svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.35;
}

.step-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.step-card-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.step-bank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.step-bank-row img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.step-bank-row span {
  font-size: 14px;
  font-weight: 600;
}

.step-section {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.step-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.step-body {
  padding: 16px 18px 20px;
}

.step-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}

.step-images {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-images img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fafafa;
  cursor: zoom-in;
}

.step-nav-footer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 4px;
}

.btn-nav {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

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

.btn-nav:not(:disabled):active {
  background: var(--bg);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  padding: calc(var(--app-chrome-top) + 16px)
    calc(16px + var(--app-safe-right))
    calc(16px + var(--app-safe-bottom))
    calc(16px + var(--app-safe-left));
}

.lightbox.is-open {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: calc(var(--app-safe-top) + var(--app-top-offset) + 12px);
  right: calc(16px + var(--app-safe-right));
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

/* iOS 刘海屏 / 全面屏 WebView */
@supports (-webkit-touch-callout: none) {
  .layout {
    min-height: 0;
  }

  .sidebar,
  .content {
    -webkit-overflow-scrolling: touch;
  }
}

/* 手机：首页全屏目录，详情全屏内容 */
@media (max-width: 767px) {
  .layout.view-home .sidebar {
    width: 100%;
    border-right: none;
  }

  .layout.view-detail .sidebar {
    display: none;
  }

  .layout.view-detail .content {
    width: 100%;
  }
}

/* 平板/桌面：首页侧栏 + 详情区；返回按钮在详情页显示 */
@media (min-width: 768px) {
  .layout.view-home .sidebar {
    width: min(100%, 420px);
    max-width: 100%;
  }

  .layout.view-home .content {
    display: none;
  }

  .layout.view-detail {
    flex-direction: row;
  }

  .layout.view-detail .sidebar {
    display: block;
    width: var(--sidebar-width);
  }

  .layout.view-detail .content {
    display: block;
    flex: 1;
  }

