/* ============================================================
   S2 前台 · 参考站布局 + 蔚蓝/白配色
   移动端优先
   ============================================================ */

:root {
  --bg-top: #F5FAFF;
  --bg-bottom: #E4F0FF;
  --card: #FFFFFF;
  --primary: #3D8BFF;
  --primary-deep: #2F7DF6;
  --primary-soft: #E3EFFF;
  --blue: #2F7DF6;
  --blue-soft: #E8F1FF;
  --text: #1F2937;
  --text-2: #6B7A90;
  --text-3: #9AA8BC;
  --line: #E8EFF7;
  --green: #34C759;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(47, 125, 246, 0.08);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
input { font-family: inherit; border: none; outline: none; background: none; color: var(--text); }
input::placeholder { color: var(--text-3); }
img { display: block; }

#app { max-width: 520px; margin: 0 auto; padding: 0 16px; }
#app svg { flex-shrink: 0; }

/* ---------------- 品牌区 ---------------- */
.brand { text-align: center; padding: 14px 0 2px; }
.brand-logo {
  width: 58px; height: 58px; margin: 0 auto 8px;
  border-radius: 17px;
  background: linear-gradient(135deg, #5AA0FF, #2F7DF6);
  box-shadow: 0 8px 18px rgba(47, 125, 246, 0.28);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-logo .brand-logo-fallback { color: #fff; font-size: 28px; font-weight: 700; }
.brand-name {
  font-size: 20px; font-weight: 700; letter-spacing: 0.5px;
  color: #1F2937;
}
.brand-slogan { margin-top: 4px; font-size: 12.5px; color: var(--text-2); }

/* ---------------- 公告条 ---------------- */
.notice-bar {
  margin: 10px 0 0;
  display: flex; align-items: center; gap: 8px;
  background: rgba(47, 125, 246, 0.07);
  border: 1px solid rgba(47, 125, 246, 0.18);
  color: var(--primary-deep);
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 12px;
  line-height: 1.5;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.notice-bar svg { flex-shrink: 0; width: 15px; height: 15px; }

/* ---------------- 快捷导航 ---------------- */
.quick-nav { display: flex; gap: 10px; margin: 10px 0 0; }
.qn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #fff;
  border-radius: 12px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--primary-deep);
  font-weight: 500;
  box-shadow: 0 3px 10px rgba(47, 125, 246, 0.06);
  transition: transform 0.1s ease;
}
.qn-item:active { transform: scale(0.96); }
.qn-item svg { width: 18px; height: 18px; display: block; }

/* ---------------- 卡片 ---------------- */
.cards { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px;
}

.card-row { display: flex; align-items: center; gap: 12px; }
.card-label {
  flex-shrink: 0;
  width: 58px;
  font-size: 15px; font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.card-label svg { width: 17px; height: 17px; color: var(--primary); }

.input-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.input-wrap input {
  flex: 1; min-width: 0;
  height: 44px;
  background: #F3F7FC;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 14px;
}
.input-wrap input:focus { background: #F2F8FF; box-shadow: 0 0 0 1.5px var(--primary); }

.mini-btn {
  flex-shrink: 0;
  height: 44px; padding: 0 16px;
  background: linear-gradient(135deg, #5AA0FF, var(--primary-deep));
  color: #fff;
  font-size: 13px; font-weight: 600;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(47, 125, 246, 0.25);
}
.mini-btn:active { transform: scale(0.96); }
.mini-btn.mini-btn--ghost { background: var(--primary-soft); color: var(--primary-deep); box-shadow: none; }

/* ---------------- 安装方式 ---------------- */
.seg {
  display: flex; gap: 8px;
  background: #F3F7FC;
  border-radius: 12px;
  padding: 4px;
}
.seg-item {
  flex: 1; text-align: center;
  padding: 10px 0;
  font-size: 14px; color: var(--text-2);
  border-radius: 9px;
  transition: all 0.15s ease;
}
.seg-item.active {
  background: #fff;
  color: var(--primary-deep);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(47, 125, 246, 0.12);
}

/* 后台应用按钮组：按应用数量渲染，3 列换行，带应用图标 */
.app-seg { flex-wrap: wrap; margin: 10px 0 14px; }
.app-seg .seg-item {
  flex: 1 1 calc(33.333% - 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}
.app-seg .app-seg-ico {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 6px;
  overflow: hidden;
  background: #E9F1FC;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: #9FB6D6;
}
.app-seg .app-seg-ico img { width: 100%; height: 100%; object-fit: cover; }
.app-seg .app-seg-ico .app-seg-ico-fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.app-seg .app-seg-name {
  min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* ---------------- 应用选择行 ---------------- */
.app-select {
  display: flex; align-items: center; gap: 6px;
  margin: 10px 0 10px;
  padding: 9px 12px;
  background: #F3F7FC;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px; color: var(--text-2);
  transition: background 0.15s ease;
}
.app-select:active { background: #E9F2FE; }
.app-select .app-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.app-select b {
  color: var(--text); font-weight: 600;
  max-width: 55%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.app-select .app-chev { margin-left: auto; color: var(--text-3); font-size: 16px; line-height: 1; }

.install-btn {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #5AA0FF, #2F7DF6);
  color: #fff;
  font-size: 16px; font-weight: 700; letter-spacing: 2px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(47, 125, 246, 0.30);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.install-btn svg { width: 19px; height: 19px; }
.install-btn:active { transform: scale(0.98); }
.install-btn:disabled { opacity: 0.65; }
.install-btn .spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 说明 ---------------- */
.guide h3 {
  display: flex; align-items: center; gap: 7px;
  font-size: 15px; font-weight: 600; color: var(--text);
  margin-bottom: 10px;
}
.guide h3 svg { width: 17px; height: 17px; color: var(--blue); }
.guide h3 + ul { margin-bottom: 14px; }
.guide ul { list-style: none; }
.guide li {
  position: relative;
  padding-left: 16px;
  font-size: 13px; color: var(--text-2);
  line-height: 1.9;
}
.guide li::before {
  content: ""; position: absolute; left: 2px; top: 12px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
}

/* ---------------- 页脚 ---------------- */
.foot { text-align: center; font-size: 12px; color: var(--text-3); padding: 26px 0 8px; }

/* ---------------- 子页面头部 ---------------- */
.sub-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 0 14px;
}
.back-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 20px; line-height: 1;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.sub-header h2 { font-size: 18px; font-weight: 700; }

/* ---------------- 帮助页 ---------------- */
.help-list { display: flex; flex-direction: column; gap: 10px; }
.help-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.help-item h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.help-item p { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.help-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.help-detail .help-content { font-size: 13.5px; color: var(--text); line-height: 1.85; }
.help-detail .help-content p { margin-bottom: 8px; color: var(--text); }
.help-detail .help-content strong { color: var(--blue); }
.help-empty { text-align: center; color: var(--text-3); font-size: 14px; padding: 60px 0; }

/* ---------------- 短链安装页 ---------------- */
.app-install {
  text-align: center;
  padding: 50px 0 0;
}
.app-install .app-icon {
  width: 92px; height: 92px;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: #F0F4FA;
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
  overflow: hidden;
}
.app-install .app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-install .app-icon .app-icon-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: #B9C6D8; font-size: 36px; font-weight: 700;
}
.app-install h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.app-install .app-meta { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.app-install .app-bid {
  font-size: 11px; color: var(--text-3);
  max-width: 80%; margin: 0 auto 28px;
  word-break: break-all;
}
.app-install .install-btn { max-width: 320px; margin: 0 auto; }

/* ---------------- 应用选择弹窗 ---------------- */
.app-picker { max-height: 56vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.picker-group + .picker-group { margin-top: 14px; }
.picker-group-title {
  font-size: 12px; color: var(--text-3);
  margin: 0 4px 8px;
}
.picker-item {
  display: flex; align-items: center; gap: 12px;
  background: #F8FAFD;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.picker-item:active { background: #EFF6FF; }
.picker-item.selected { background: #EFF6FF; border-color: rgba(47, 125, 246, 0.35); }
.picker-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 12px;
  background: #E9F1FC;
  overflow: hidden;
}
.picker-icon img { width: 100%; height: 100%; object-fit: cover; }
.picker-icon .picker-icon-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: #9FB6D6; font-size: 20px; font-weight: 700;
}
.picker-main { flex: 1; min-width: 0; }
.picker-main .picker-name { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.picker-main .picker-meta { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.picker-check { color: var(--primary); flex-shrink: 0; width: 18px; height: 18px; }
.picker-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 30px 0; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 60px;
  transform: translateX(-50%);
  max-width: 80%;
  background: rgba(31, 41, 55, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 10px;
  z-index: 200;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 520px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slide-up 0.25s ease;
}
@keyframes slide-up { from { transform: translateY(40px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.modal .modal-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: #E5EDF7; margin: 0 auto 16px;
}
.modal h3 { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 14px; }
.modal .modal-body { font-size: 14px; color: var(--text); line-height: 1.8; }
.modal .modal-body p { margin-bottom: 8px; }

.kf-list { display: flex; flex-direction: column; gap: 10px; }
.kf-item {
  display: flex; align-items: center; gap: 12px;
  background: #F8FAFD;
  border-radius: 12px;
  padding: 13px 14px;
}
.kf-item .kf-ico {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-soft); color: var(--blue);
}
.kf-item .kf-ico svg { width: 18px; height: 18px; }
.kf-item .kf-label { font-size: 12px; color: var(--text-2); }
.kf-item .kf-value { font-size: 14px; font-weight: 600; word-break: break-all; }
.kf-item a.kf-value { color: var(--blue); }

.agree-row {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px 0 16px;
  font-size: 13px; color: var(--text-2); line-height: 1.6;
}
.agree-row input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.agree-row b { color: var(--primary-deep); font-weight: 600; }

.modal-actions { display: flex; gap: 12px; }
.modal-actions button {
  flex: 1; height: 46px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
}
.modal-actions .m-cancel { background: #F2F6FB; color: var(--text-2); }
.modal-actions .m-ok {
  background: linear-gradient(135deg, #5AA0FF, var(--primary-deep));
  color: #fff;
  box-shadow: 0 6px 16px rgba(47, 125, 246, 0.25);
}
.modal-actions .m-ok:disabled { opacity: 0.5; }

/* ---------------- 加载骨架 ---------------- */
.page-loading { text-align: center; padding: 80px 0; color: var(--text-3); font-size: 14px; }
.page-loading .ld-ring {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid #DCE9FA; border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

/* ---------------- 桌面宽屏适配 ---------------- */
@media (min-width: 640px) {
  #app { max-width: 680px; padding: 0 24px; }
  .brand { padding: 36px 0 10px; }
  .brand-logo { width: 78px; height: 78px; margin-bottom: 12px; }
  .brand-name { font-size: 26px; }
  .brand-slogan { font-size: 14px; }
  .cards { gap: 12px; }
  .card { padding: 18px; }
  .input-wrap input { height: 48px; font-size: 15px; }
  .mini-btn { height: 48px; font-size: 14px; padding: 0 20px; }
  .install-btn { height: 52px; font-size: 17px; }
  .guide li { font-size: 13.5px; }
}
