/* ==========================================================================
   设计令牌（CSS 自定义属性）
   统一管理颜色、圆角等视觉参数，修改此处即可全局生效
   ========================================================================== */
:root {
  /* 主题色 */
  --blue: #a9c9ff;           /* 主色调：按钮、星级、高亮 */
  --green: #34c759;          /* 成功色：默认头像背景 */

  /* 背景色（从深到浅） */
  --bg: #0f0f10;             /* 全局底色 */
  --bg-card: #111112;        /* 卡片/容器底色 */
  --bg-elevated: #202028;    /* 浮层/输入框底色 */

  /* 文字色（从亮到暗） */
  --text: #f3f3f6;           /* 主文字 */
  --text-secondary: #b8b8c0; /* 次要文字 */
  --text-tertiary: #aaaab3;  /* 辅助文字（提示、占位等） */

  /* 边框与分割线 */
  --border: #24242c;         /* 实线边框 */
  --border-light: #2b2b34;   /* 浅边框 */
  --divider: #202027;        /* 分区背景分割线 */

  /* 圆角 */
  --radius-sm: 4px;          /* 小圆角：徽章、条形 */
  --radius-md: 8px;          /* 中圆角：截图卡片、输入框 */
  --radius-lg: 18px;         /* 大圆角：应用图标 */
  --radius-pill: 28px;       /* 胶囊圆角：下载按钮 */
}

/* ==========================================================================
   全局重置
   统一盒模型、清除默认边距，确保跨浏览器一致性
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow-x: hidden; /* 防止横向滚动条 */
}

/* ==========================================================================
   主页面布局
   移动端优先设计，最大宽度 430px，居中显示
   整体为深色主题暗色应用商店风格
   ========================================================================== */

/* 手机外壳 —— 页面主容器，限制最大宽度模拟手机屏幕 */
.phone-shell {
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg-card);
  min-height: 100vh;
  padding: 18px 16px 28px;
  position: relative;
}

/* ---------- 1. 应用头部（图标 + 标题 + 副标题 + 评分徽章） ---------- */

.app-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 4px 0 12px;
}

/* 应用图标容器：86x86，圆角 18px，固定不缩放 */
.app-icon {
  width: 86px;
  height: 86px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  flex-shrink: 0; /* 防止被压缩 */
  display: grid;
  place-items: center;
  box-shadow: rgba(255, 255, 255, 0.08) 0 1px 0, rgba(0, 0, 0, 0.45) 0 8px 30px;
  overflow: hidden;
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 图片填充裁剪，保持比例 */
}

.icon-placeholder {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 8px;
}

/* 标题文字区域：flex 自动填充剩余空间 */
.head-text {
  flex: 1 1 0%;
  min-width: 0; /* 防止 flex 子元素溢出 */
}

.head-text h1 {
  font-size: 25px;
  line-height: 1.22;
  margin: 0 0 6px;
  font-weight: 780;
  letter-spacing: -0.3px;
}

.app-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* 评分徽章组 */
.install-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 评分数字徽章：白底黑字方块 */
.badge-rating {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: white;
  color: var(--bg-card);
  font-weight: 900;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.badge-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- 2. 元数据行（评分|年龄|下载量，三列等分） ---------- */

.meta-row {
  display: grid;
  grid-template-columns: 1fr 1px 1fr 1px 1fr; /* 竖线分隔符占 1px */
  align-items: center;
  text-align: center;
  margin: 16px 0 22px;
}

.meta-item {
  min-width: 0;
  padding: 0 4px;
}

.meta-item strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
  white-space: normal;
  line-height: 1.2;
}

.meta-item strong span {
  color: var(--blue);
  margin-left: 2px;
}

.meta-item small {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.2;
}

/* 竖线分隔符：高 36px，居中对齐 */
.meta-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  justify-self: center;
}

/* ---------- 3. 下载按钮（胶囊形，蓝色，含脉冲动画） ---------- */

.install-btn {
  display: block;
  background: var(--blue);
  color: #07101f;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-pill);
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 22px;
  transition: opacity 0.2s ease;
}

.install-btn:hover {
  opacity: 0.9;
}

.install-btn:active {
  opacity: 0.8;
}

/* 脉冲呼吸动画：引导用户点击下载按钮 */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(169, 201, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(169, 201, 255, 0);
  }
}

/* ---------- 4. 截图横向滚动条 ---------- */

.shot-strip {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 0 0 20px;
  scroll-snap-type: x mandatory; /* 滚动吸附效果 */
  -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
  margin: 0 -16px; /* 负边距使滚动条延伸到屏幕边缘 */
  padding-left: 16px;
  padding-right: 16px;
}

/* 隐藏滚动条：WebKit 浏览器 */
.shot-strip::-webkit-scrollbar {
  display: none;
}

/* 隐藏滚动条：Firefox 及 IE */
.shot-strip {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* 截图卡片：104x194，竖版比例 */
.shot-item {
  flex: 0 0 auto;
  width: 104px;
  height: 194px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  scroll-snap-align: start;
  border: 1px solid var(--border-light);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.shot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shot-placeholder {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 8px;
}

/* ---------- 5. 分区卡片（关于 / 评分与评论） ---------- */

/* 分区卡片容器：顶部 8px 分割线 */
.section-card {
  border-top: 8px solid var(--divider); /* 使用背景色作为分割 */
  padding: 20px 0 10px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

/* 分区标题行：标题居左，箭头居右 */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 20px;
  margin: 0;
  font-weight: 760;
}

/* 右箭头 */
.chevron {
  font-size: 24px;
  color: var(--text-tertiary);
  font-weight: 300;
  line-height: 1;
}

/* ---------- 5a. 关于此应用 ---------- */

.about-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.about-content p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.75;
  margin: 0 0 14px;
  max-height: 124px; /* 限制高度，超出隐藏 */
  overflow: hidden;
  position: relative;
}

.about-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---------- 5b. 评分区 ---------- */

/* 评分总览：左侧大数字 + 右侧条形图 */
.rating-box {
  display: grid;
  grid-template-columns: 126px 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}

.rating-main {
  text-align: center;
}

/* 评分大数字：64px 细体 */
.rating-num {
  font-size: 64px;
  line-height: 0.9;
  font-weight: 300;
  letter-spacing: -2px;
}

.stars,
.review-stars span {
  color: var(--blue);
  letter-spacing: 1px;
  font-size: 14px;
}

.rating-main small {
  display: block;
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 13px;
}

/* 评分分布条形图：5 行纵向排列 */
.rating-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* 条形背景轨道 */
.bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

/* 条形填充：蓝色，宽度由 JS 动态设置 */
.bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ---------- 5c. 评论列表 ---------- */

.reviews-list {
  display: flex;
  flex-direction: column;
}

/* 单条评论：上边框分隔 */
.review-card {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

/* 第一条评论无上边框 */
.review-card:first-of-type {
  border-top: none;
  padding-top: 0;
}

/* 评论头部：头像 + 用户名 + 更多按钮 */
.review-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 用户头像：42px 圆形，绿色背景 */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.review-name {
  flex: 1 1 0%;
  font-size: 15px;
  font-weight: 600;
}

/* 更多操作按钮 */
.more {
  font-size: 26px;
  color: var(--text-secondary);
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.review-stars {
  margin: 13px 0 8px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.review-stars em {
  font-style: normal;
  color: var(--text-tertiary);
  font-size: 13px;
}

.review-card p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.review-card small {
  color: var(--text-tertiary);
  font-size: 13px;
}

/* 有用评价按钮组 */
.helpful {
  margin-top: 16px;
  color: var(--text-tertiary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.helpful button {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text);
  border-radius: 10px;
  min-width: 52px;
  padding: 8px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.helpful button:hover {
  background: var(--bg-elevated);
}

.helpful button:active {
  background: var(--border);
}

/* ---------- 6. 页脚 ---------- */

.page-footer {
  padding: 24px 0 8px;
  text-align: center;
}

/* 管理后台入口链接：低透明度，hover 显示 */
.admin-link {
  color: var(--text-tertiary);
  font-size: 13px;
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.admin-link:hover {
  opacity: 1;
}

/* ==========================================================================
   响应式设计
   根据屏幕宽度自动调整布局和字体大小
   ========================================================================== */

/* 小屏手机（<= 360px）：缩小标题、图标和评分数字 */
@media (max-width: 360px) {
  .head-text h1 {
    font-size: 22px;
  }

  .app-icon {
    width: 78px;
    height: 78px;
  }

  .rating-box {
    grid-template-columns: 108px 1fr;
    gap: 12px;
  }

  .rating-num {
    font-size: 58px;
  }

  .shot-item {
    width: 96px;
    height: 180px;
  }
}

/* 平板/桌面端（>= 768px）：卡片化呈现，带圆角和阴影 */
@media (min-width: 768px) {
  .phone-shell {
    margin-top: 24px;
    margin-bottom: 24px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    min-height: auto;
  }

  body {
    background: var(--bg);
    padding: 20px;
  }
}

/* ==========================================================================
   管理后台页面样式
   独立于主页面布局，最大宽度 800px 居中
   ========================================================================== */

.admin-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px;
}

.admin-page h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.admin-page .admin-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}

/* 管理分区：带边框的卡片 */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.admin-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* 表单控件通用样式 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

/* 输入框 / 文本域 / 下拉框统一样式 */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

/* 聚焦时高亮边框 */
.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* 表单提示文字 */
.form-group .hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* 双列表单行 */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* 按钮通用样式 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
  font-family: inherit;
}

/* 主要按钮：蓝色 */
.btn-primary {
  background: var(--blue);
  color: #07101f;
}

/* 次要按钮：深色描边 */
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  opacity: 0.8;
}

/* 按钮组：横向排列 */
.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* 底部操作栏 */
.admin-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* 截图上传网格：自适应列数 */
.screenshot-uploader {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* 截图上传项：保持竖版比例 */
.screenshot-item {
  aspect-ratio: 104 / 194;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.screenshot-item:hover {
  border-color: var(--blue);
}

.screenshot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screenshot-item .upload-icon {
  font-size: 24px;
  color: var(--text-tertiary);
}

/* 截图删除按钮：hover 时才显示 */
.screenshot-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.screenshot-item:hover .remove-btn {
  display: flex;
}

/* 图标上传器：86x86，与主页面图标尺寸一致 */
.icon-uploader {
  width: 86px;
  height: 86px;
  border: 2px dashed var(--border);
  border-radius: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color 0.2s ease;
  overflow: hidden;
}

.icon-uploader:hover {
  border-color: var(--blue);
}

.icon-uploader img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-uploader .upload-icon {
  font-size: 20px;
  color: var(--text-tertiary);
}

/* 评论编辑项 */
.review-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.review-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.review-item-header h3 {
  font-size: 14px;
  font-weight: 600;
}

/* 删除评论按钮：hover 变红色警示 */
.remove-review-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.remove-review-btn:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

/* 保存成功提示：绿色横幅，默认隐藏 */
.success-message {
  background: rgba(52, 199, 89, 0.15);
  border: 1px solid rgba(52, 199, 89, 0.3);
  color: #34c759;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
}

.success-message.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 管理后台响应式：小屏时表单改为单列 */
@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .admin-section {
    padding: 16px;
  }

  .admin-page {
    padding: 16px 12px;
  }
}
