/* ============================================================
   iOS 签名站样式表
   前台：App Store 风格（浅色、分组卡片、底部弹出面板）
   后台：复用前台浅色卡片风格（白卡 + 蓝色主色 + 胶囊导航）
   兼容约束（iOS 13/14）：不使用 inset 简写 / :has() / backdrop-filter /
   aspect-ratio / clamp() / flex gap；不使用 IntersectionObserver 相关样式
   ============================================================ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #f2f2f7;
  color: #1c1c1e;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

a, button { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
button { font-family: inherit; }
img { border: 0; }

/* ============================ 顶部导航 ============================ */
.topbar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 1px solid #ececf0;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 700px; margin: 0 auto; padding: 10px 16px 12px; }
.topbar-row { display: flex; align-items: flex-end; justify-content: space-between; }
.topbar-titlebox { flex: 1 1 auto; min-width: 0; }
.topbar-kicker { font-size: 12px; font-weight: 600; color: #8e8e93; letter-spacing: 0.02em; }
.topbar-title { font-size: 30px; line-height: 1.12; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
/* 搜索框 */
.search-box {
  display: flex; align-items: center; height: 38px;
  margin-top: 12px; padding: 0 10px;
  background: #efeff4; border-radius: 12px;
}
.search-ico { width: 17px; height: 17px; flex: 0 0 auto; color: #8e8e93; }
.search-input {
  flex: 1; min-width: 0; height: 38px; margin-left: 8px;
  border: 0; background: transparent; outline: none;
  font-size: 15px; color: #1c1c1e; -webkit-appearance: none; appearance: none;
}
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-clear {
  flex: 0 0 auto; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: #c7c7cc;
  color: #ffffff; font-size: 13px; line-height: 18px; text-align: center;
}

/* ============================ 页面容器 ============================ */
.page { max-width: 700px; margin: 0 auto; padding-bottom: 28px; }

/* ============================ 今日推荐 ============================ */
.featured { padding: 16px 16px 2px; }
.featured-card {
  position: relative; overflow: hidden;
  padding: 20px; border-radius: 22px; color: #ffffff;
  background: linear-gradient(140deg, #0b1b33 0%, #123a63 52%, #0a6cd6 100%);
  box-shadow: 0 14px 30px rgba(9, 44, 92, 0.24);
}
.featured-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #8dc0ff; }
.featured-main { display: flex; align-items: center; margin-top: 14px; }
.featured-icon { width: 64px; height: 64px; flex: 0 0 auto; border-radius: 16px; object-fit: cover; background: rgba(255,255,255,0.14); }
.featured-icon-ph {
  width: 64px; height: 64px; flex: 0 0 auto; border-radius: 16px;
  background: rgba(255,255,255,0.14); color: rgba(255,255,255,0.75);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.featured-text { flex: 1; min-width: 0; margin-left: 14px; }
.featured-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.featured-meta { margin-top: 5px; font-size: 12px; color: rgba(255,255,255,0.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.featured-desc { margin-top: 10px; font-size: 13px; line-height: 1.6; color: rgba(255,255,255,0.78); }
.featured-btn {
  display: block; width: 100%; margin-top: 16px; padding: 11px;
  border: 0; border-radius: 13px;
  background: rgba(255,255,255,0.94); color: #0a3d78;
  font-size: 15px; font-weight: 700;
}
.featured-btn:active { background: rgba(255,255,255,0.8); }

/* ==================== 分类横排（横向滚动胶囊） ==================== */
.cat-scroll {
  padding: 12px 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cat-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
.cat-pills {
  display: flex;
  align-items: center;
  padding: 0 16px;
  white-space: nowrap;
}
.cat-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 34px;
  margin-right: 8px;
  padding: 0 14px;
  border: 1px solid #e3e3e9;
  border-radius: 100px;
  background: #ffffff;
  color: #1c1c1e;
  font-size: 14px;
  font-family: inherit;
  white-space: nowrap;
}
.cat-pill:last-child { margin-right: 0; }
.cat-pill:active { background: #f2f2f7; }
.cat-pill.active {
  border-color: #007aff;
  background: #007aff;
  color: #ffffff;
  font-weight: 600;
}
.cat-pill-num { margin-left: 6px; font-size: 12px; opacity: 0.72; }

/* ============================ 应用分组 ============================ */
.sections { padding: 6px 16px 0; }
.group { margin-top: 18px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 8px; }
.group-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.group-count { font-size: 12px; color: #8e8e93; }
.card { background: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); }

.app-row {
  display: flex; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid #f1f1f5;
}
.app-row:last-child { border-bottom: 0; }
.app-row:active { background: #f6f6fa; }
.app-icon { width: 60px; height: 60px; flex: 0 0 auto; border-radius: 14px; object-fit: cover; background: #eef1f5; display: block; }
.app-icon-ph {
  width: 60px; height: 60px; flex: 0 0 auto; border-radius: 14px;
  background: #eef1f5; color: #a1a1a6; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.app-text { flex: 1; min-width: 0; margin-left: 12px; }
.app-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sub { margin-top: 3px; font-size: 12px; color: #8e8e93; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-tags { margin-top: 6px; }
.tag-cat { display: inline-block; padding: 2px 8px; border-radius: 7px; background: #eef5ff; color: #007aff; font-size: 11px; font-weight: 500; }
.get-btn {
  flex: 0 0 auto; margin-left: 10px; padding: 7px 18px;
  border: 0; border-radius: 100px; background: #eef5ff; color: #007aff;
  font-size: 14px; font-weight: 600;
}
.get-btn:active { background: #dbe8ff; }

/* 空状态 / 加载 */
.state-box { padding: 56px 24px; text-align: center; color: #8e8e93; font-size: 14px; line-height: 1.7; }
.state-title { display: block; margin-bottom: 6px; font-size: 16px; font-weight: 600; color: #3c3c43; }
.spinner {
  display: inline-block; width: 16px; height: 16px; margin-right: 6px;
  border: 2px solid #d7d7dd; border-top-color: #007aff; border-radius: 50%;
  vertical-align: -3px; animation: spin 0.8s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============================ 表单与按钮 ============================ */
.field { margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: #8e8e93; }
.field-row { display: flex; align-items: center; }
.field-row .input { flex: 1; min-width: 0; }
.input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid #e0e0e6; border-radius: 12px;
  background: #fbfbfd; color: #1c1c1e; font-size: 15px;
  font-family: inherit; outline: none;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: #b3b3b8; }
.input:focus { border-color: #007aff; background: #ffffff; }
.field-hint { margin-top: 6px; font-size: 11px; line-height: 1.6; color: #a1a1a6; }
.field-hint.hint-danger { color: #ff3b30; font-weight: 500; }

.steps-box { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #dbe7ff; border-radius: 14px; background: #f5f8ff; }
.steps-title { margin-bottom: 8px; font-size: 13px; font-weight: 700; color: #0b4a9c; }
.steps-text { margin-top: 10px; font-size: 12px; line-height: 1.7; color: #3d5c85; }
.steps-wait { margin-top: 8px; font-size: 12px; line-height: 1.65; color: #007aff; }

.error-text { margin: 2px 2px 12px; font-size: 13px; line-height: 1.6; color: #ff3b30; }

.result-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid #f1f1f5; }
.result-title { margin-bottom: 10px; font-size: 13px; color: #3c3c43; }
.result-note { margin-top: 10px; font-size: 11px; line-height: 1.7; color: #a1a1a6; }

.btn {
  display: inline-block; padding: 11px 16px;
  border: 0; border-radius: 12px;
  font-size: 15px; font-weight: 600; text-align: center;
  text-decoration: none; cursor: pointer; font-family: inherit;
  transition: opacity 0.15s ease-out;
}
.btn:active { opacity: 0.82; }
.btn:disabled { opacity: 0.5; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 14px 16px; font-size: 16px; border-radius: 14px; }
.btn-primary { background: #007aff; color: #ffffff; }
.btn-soft { flex: 0 0 auto; margin-left: 8px; padding: 10px 14px; background: #eef5ff; color: #007aff; font-size: 14px; }
.btn-line { background: #ffffff; color: #1c1c1e; border: 1px solid #dcdce2; }
.btn-install { background: linear-gradient(180deg, #0a84ff, #0066d6); color: #ffffff; box-shadow: 0 6px 16px rgba(0, 122, 255, 0.26); }
.btn-block + .btn-block { margin-top: 10px; }

/* ============================ 宽屏适配 ============================ */
@media (min-width: 720px) {
  .topbar-inner { padding-left: 24px; padding-right: 24px; }
  .featured { padding-left: 24px; padding-right: 24px; }
  .cat-scroll { padding-left: 0; padding-right: 0; }
  .sections { padding-left: 24px; padding-right: 24px; }
  .topbar-title { font-size: 34px; }
}

/* ============================ 后台（与前台一致的浅色风格） ============================ */
.admin-body {
  background: #f2f2f7;
  min-height: 100vh;
  color: #1c1c1e;
}
.admin-body .container { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
/* 后台头部与内容同宽，保证标题与卡片左边界对齐 */
.admin-body .topbar-inner { max-width: 1000px; padding-left: 16px; padding-right: 16px; }

/* 后台头部：令牌行 */
.admin-token-row { display: flex; align-items: center; margin-top: 12px; }
.admin-token-row .input { flex: 0 1 240px; height: 40px; }
.admin-token-row .btn { flex: 0 0 auto; margin-left: 8px; padding: 10px 16px; font-size: 14px; }
.token-msg { margin-left: 10px; font-size: 12px; color: #1a9d4c; }

/* 导航：胶囊式，对齐前台分类胶囊 */
.tabs { display: flex; flex-wrap: wrap; padding: 14px 0 6px; }
.tab {
  margin: 0 8px 8px 0; padding: 0 16px; height: 34px; line-height: 32px;
  border: 1px solid #e3e3e9; border-radius: 100px;
  background: #ffffff; color: #1c1c1e;
  font-size: 14px; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.tab:active { background: #f2f2f7; }
.tab.active { border-color: #007aff; background: #007aff; color: #ffffff; font-weight: 600; }

/* 面板：白色分组卡片 */
.tab-panel {
  margin-bottom: 28px; padding: 16px;
  background: #ffffff; border: 0; border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.panel-head { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 12px; }
.panel-head h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: #1c1c1e; }
.panel-hint { margin-left: 8px; font-size: 12px; color: #8e8e93; }
.panel-head .btn { flex: 0 0 auto; }
.panel-sub { padding: 0 2px 8px; font-size: 12px; line-height: 1.7; color: #a1a1a6; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-body th, .admin-body td {
  padding: 11px 10px; text-align: left;
  border-bottom: 1px solid #f1f1f5; white-space: nowrap; color: #1c1c1e;
}
.admin-body thead th {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: #8e8e93; border-bottom: 1px solid #ececf0;
}
.admin-body tbody tr:last-child td { border-bottom: 0; }
.admin-body tbody tr:hover { background: #f6f6fa; }
td .cell-icon { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; background: #eef1f5; }

/* 标签 */
.tag { display: inline-block; padding: 3px 9px; border-radius: 7px; font-size: 12px; font-weight: 500; }
.tag-on { background: #e9f8ee; color: #1a9d4c; }
.tag-off { background: #ffedec; color: #ff3b30; }
.tag-cat-admin { background: #eef5ff; color: #007aff; }

/* 按钮：沿用前台圆角体系 */
.admin-body .btn { padding: 9px 15px; border-radius: 11px; font-size: 14px; box-shadow: none; }
.admin-body .btn-primary { background: #007aff; color: #ffffff; }
.admin-body .btn-secondary { background: #ffffff; color: #007aff; border: 1px solid #dcdce2; }
.admin-body .btn-secondary:active { background: #f2f2f7; }
.mini-btn { margin-right: 6px; padding: 5px 13px; font-size: 12px; border-radius: 100px; }
.admin-body .btn-secondary.mini-btn { background: #eef5ff; color: #007aff; border: 0; }
.admin-body .btn-secondary.mini-btn:active { background: #dbe8ff; }

/* 输入控件：对齐前台 .input */
.admin-body input, .admin-body select {
  width: auto; height: 42px; padding: 0 12px;
  border: 1px solid #e0e0e6; border-radius: 12px;
  background: #fbfbfd; color: #1c1c1e; font-size: 15px; font-family: inherit;
  outline: none; -webkit-appearance: none; appearance: none;
}
.admin-body input::placeholder { color: #b3b3b8; }
.admin-body input:focus, .admin-body select:focus { border-color: #007aff; background: #ffffff; }
.admin-body .form-group input, .admin-body .form-group select { width: 100%; }

/* 上传与提示 */
.upload-box { padding: 4px 0; }
.upload-box input[type="file"] {
  width: 100%; height: auto; padding: 12px; border-style: dashed;
  border-radius: 14px; background: #fbfbfd; color: #3c3c43; font-size: 13px;
}
.upload-box .form-group { margin-bottom: 18px; }
.upload-tip { margin-top: 14px; font-size: 12px; line-height: 1.7; color: #a1a1a6; }
.progress-wrap { margin-top: 14px; height: 8px; border-radius: 100px; background: #ececf0; overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: 100px; background: #007aff; transition: width 0.2s ease-out; }
.msg-text { margin-top: 10px; font-size: 13px; line-height: 1.6; color: #1a9d4c; }

/* 表单 */
.form-box .form-group { max-width: 560px; }
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: #8e8e93;
}

/* 分类管理：新增行与选择行 */
.admin-body .cat-add-row { display: flex; align-items: center; flex-wrap: wrap; }
.admin-body .cat-add-row input { width: 220px; margin-right: 8px; margin-bottom: 6px; }
.admin-body .cat-add-row .sort-input { width: 220px; }
.admin-body .cat-add-row .btn { margin-bottom: 6px; }
.admin-body .cat-pick-row { display: flex; align-items: center; }
.admin-body .cat-pick-row input { flex: 1 1 auto; min-width: 0; margin-right: 8px; width: auto; cursor: pointer; }
.admin-body .cat-pick-row .btn { flex: 0 0 auto; }

/* 后台分类选择层（底部弹出，同前台 picker） */
.picker-mask {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 120;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}
.picker-panel {
  display: flex; flex-direction: column;
  width: 100%; max-width: 520px; max-height: 72vh;
  background: #ffffff; border-radius: 16px 16px 0 0; overflow: hidden;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}
.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 auto; padding: 14px 16px; border-bottom: 1px solid #ececf0;
}
.picker-title { font-size: 16px; font-weight: 700; color: #1c1c1e; }
.picker-close { border: 0; background: transparent; color: #8e8e93; font-size: 14px; font-family: inherit; cursor: pointer; }
.picker-list {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 16px;
}
.picker-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 13px 2px;
  border: 0; border-bottom: 1px solid #f1f1f5;
  background: transparent; color: #1c1c1e;
  font-size: 15px; font-family: inherit; text-align: left; cursor: pointer;
}
.picker-item:last-child { border-bottom: 0; }
.picker-item:active { background: #f6f6fa; }
.picker-item.active { color: #007aff; font-weight: 600; }
.picker-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-count { flex: 0 0 auto; margin-left: 10px; font-size: 12px; color: #8e8e93; }
.picker-empty { padding: 14px 2px; font-size: 13px; color: #8e8e93; }
.picker-new {
  display: flex; align-items: center; flex: 0 0 auto;
  padding: 12px 16px; border-top: 1px solid #ececf0; background: #fafafc;
}
.picker-new input {
  flex: 1 1 auto; min-width: 0; width: auto; height: 38px; margin-right: 8px;
  padding: 0 12px; border: 1px solid #e0e0e6; border-radius: 10px;
  background: #ffffff; color: #1c1c1e; font-size: 14px; font-family: inherit;
}
.picker-new .btn { flex: 0 0 auto; padding: 9px 14px; font-size: 14px; }
