/* 画语集 · 手机端专用适配
   原则：桌面端样式完全不动，这里只在移动断点内覆盖。
   显隐一律用内联 style.display，本文件不碰 hidden 属性。 */

/* ============ 全局：触控与安全区 ============ */

@media (max-width: 767px) {
  :root {
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --nav-h: 56px;/* 底部标签栏高度 */
  }

  html, body {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  body {
    /* 底部留出标签栏 + 安全区的空间，避免最后一条内容被盖住 */
    padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
    overscroll-behavior-y: contain;
  }

  /* 所有可点元素最小44px，符合 iOS/安卓触控规范 */
  a, button, input, select, textarea,
  .chip, .tab-btn, .act, .btn-mini, .tag-btn, .seg-btn {
    touch-action: manipulation;
  }

  button, .chip, .act, .btn-mini, .tag-btn {
    min-height: 40px;
  }

  /* 去掉长按时的选中高亮，观感更干净 */
  .card, .card-title, .ai-card, .panel {
    -webkit-user-select: none;
    user-select: none;
  }

  /* 输入框字号必须 ≥16px，否则 iOS 会自动放大页面 */
  .field input, .field textarea, .field select,
  .cmt-input input, .search-input {
    font-size: 16px;
  }
}

/* ============ 顶部栏：改为紧凑条 ============ */

@media (max-width: 767px) {
  .topbar {
    padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
    gap: 10px;
    min-height: calc(48px + var(--safe-t));
  }
  .brand-name { font-size: 16px; }
  .brand-mark { width: 28px; height: 28px; font-size: 15px; border-radius: 8px; }

  /* 移动端隐藏顶部文字导航，改用底部标签栏（拇指可达） */
  .topbar .nav { display: none !important; }

  .btn-ghost {
    margin-left: auto;
    padding: 7px 14px;
    min-height: 34px;
    font-size: 13.5px;
  }
  .ver-tag { display: none; }
}

/* ============ 底部标签栏 ============ */

.mobile-nav {
  display: none;
}

@media (max-width: 767px) {
  .mobile-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    display: flex;
    height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    padding-left: var(--safe-l);
    padding-right: var(--safe-r);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
  }
  .mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    -webkit-user-select: none;
    user-select: none;
  }
  .mobile-nav a .mi { font-size: 19px; line-height: 1; }
  .mobile-nav a.is-on { color: var(--blue); font-weight: 600; }
  .mobile-nav a:active { background: var(--blue-soft); }
}

/* 导航图标：纯 CSS 绘制，不依赖图片资源 */
.mi {
  width: 21px;
  height: 21px;
  display: block;
  position: relative;
}
.mobile-nav a .mi { margin: 0 auto; }

/* 作品集：四宫格 */
.mi-feed::before, .mi-feed::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border: 1.6px solid currentColor;
  border-radius: 1.6px;
}
.mi-feed::before { top: 2px; left: 2px; }
.mi-feed::after { bottom: 2px; right: 2px; }

/* 发布：加号圆圈 */
.mi-upload::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1.6px solid currentColor;
  border-radius: 50%;
}
.mi-upload::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 9px; height: 1.6px;
  background: currentColor;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 0 currentColor;
}
.mobile-nav a.is-on .mi-upload::after {
  box-shadow: 0 -5px 0 0 currentColor, 0 5px 0 0 currentColor;
}

/* 我的：人形 */
.mi-mine::before {
  content: '';
  position: absolute;
  top: 2px; left: 50%;
  width: 7px; height: 7px;
  border: 1.6px solid currentColor;
  border-radius: 50%;
  transform: translateX(-50%);
}
.mi-mine::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%;
  width: 15px; height: 8px;
  border: 1.6px solid currentColor;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  transform: translateX(-50%);
}

/* ============ 作品流：单列大图 ============ */

@media (max-width: 767px) {
  .app { padding: 12px 12px 24px; }

  /* 手机上双列太挤，改为单列让画看得清 */
  .grid-2, .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .img-box.cover { aspect-ratio: 4 / 3; }

  .card-body { padding: 12px 14px 14px; }
  .card-title { font-size: 15.5px; -webkit-line-clamp: 2; }
  .card-foot { font-size: 13px; gap: 14px; }
  .score-badge { font-size: 14px; }

  /* 分类筛选：横向滑动且隐藏滚动条 */
  .filters {
    gap: 6px;
    padding-bottom: 10px;
    margin: 0 -12px 12px;
    padding-left: 12px;
    padding-right: 12px;
    scrollbar-width: none;
  }
  .filters::-webkit-scrollbar { display: none; }
  .chip {
    padding: 7px 13px;
    font-size: 13px;
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* ============ 作品详情 ============ */

@media (max-width: 767px) {
  .detail-back {
    position: sticky;
    top: calc(48px + var(--safe-t));
    z-index: 40;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(10px);
    margin: -12px -12px 12px;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    min-height: 40px;
  }

  .detail-stage .img {
    max-height: 56vh;
    max-height: 56dvh;
  }
  .stage-count {
    right: 10px; bottom: 10px;
    font-size: 12px; padding: 3px 9px;
  }

  /* 缩略图条：固定在主图下方并可横滑 */
  .thumb-strip {
    padding: 10px 14px 0;
    gap: 6px;
  }
  .thumb { width: 52px; height: 52px; border-radius: 8px; }

  .detail-pad { padding: 16px 14px 18px; }
  .detail-title { font-size: 18px; margin-bottom: 12px; }

  /* 作者行改为紧凑左对齐 */
  .detail-user { gap: 9px; margin-bottom: 14px; }
  .detail-author { font-size: 14px; }
  .ava-lg { width: 34px; height: 34px; font-size: 14px; }

  /* 元信息四列改两列，避免挤压换行难看 */
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }
  .meta-cell { padding: 10px 8px; }
  .meta-v { font-size: 13.5px; }

  /* 操作栏：按钮均分等宽，拇指好点 */
  .act-bar {
    padding: 12px 14px calc(12px + var(--safe-b));
    gap: 8px;
  }
  .act {
    flex: 1;
    justify-content: center;
    min-height: 42px;
    font-size: 13.5px;
    padding: 8px 6px;
  }

  .detail-text { font-size: 15px; line-height: 1.75; }
  .tag-row { gap: 6px; }
  .tag { font-size: 12.5px; padding: 5px 11px; }
}

/* ============ 评估报告 ============ */

@media (max-width: 767px) {
  .report-card { padding: 16px 14px; }

  .ai-head { gap: 9px; margin-bottom: 14px; flex-wrap: nowrap; }
  .ai-badge { width: 32px; height: 32px; font-size: 14px; }
  .ai-title { font-size: 14.5px; }
  .ai-sub { font-size: 11px; line-height: 1.5; }
  .ai-score-v { font-size: 26px; }
  .ai-score-l { font-size: 11px; }

  .track-tag { margin: 18px 0 12px; font-size: 13.5px; }

  /* 维度条：分数放大到更醒目 */
  .dim-row { gap: 8px; }
  .dim-n { width: 44px; font-size: 12.5px; }
  .dim-bar { height: 8px; }
  .dim-s { width: 28px; font-size: 14px; }
  .dim-w { width: 32px; font-size: 10.5px; }
  /* 评语独立成行并缩进对齐名称列 */
  .dim-c {
    margin: 5px 0 12px 52px;
    font-size: 13.5px;
    line-height: 1.7;
    color: #4a5563;
  }

  /* 逐张观察：图在上文在下，竖排更好读 */
  .perimg { flex-direction: column; gap: 10px; padding: 11px; }
  .perimg-fig { width: 100%; }
  .perimg-fig .img {
    width: 100%;
    height: 190px;
    border-radius: 10px;
  }
  .perimg-title { font-size: 13px; }
  .perimg-note { font-size: 14px; line-height: 1.75; }

  .blk-t { font-size: 14.5px; line-height: 1.75; }
  .blk-no { width: 20px; height: 20px; }
  .style-v { font-size: 16px; }
  .cmp-t { font-size: 14.5px; }
  .ref-item { font-size: 12px; padding: 6px 12px; }
}

/* ============ 报告浮层：手机上全屏 ============ */

@media (max-width: 767px) {
  .report-layer { padding: 0; }
  .report-sheet {
    max-width: none;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    animation: fadeIn .16s ease-out;
  }
  @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

  .sheet-head {
    padding: calc(14px + var(--safe-t)) 16px 12px;
  }
  .sheet-title { font-size: 16.5px; }
  .sheet-sub { font-size: 12.5px; }
  .sheet-close {
    right: 10px; top: calc(10px + var(--safe-t));
    width: 34px; height: 34px; font-size: 22px;
  }

  .sheet-cover { max-height: 42vh; }
  .sheet-cover .img { max-height: 42vh; }

  .sheet-body { padding: 14px 12px; }
  .sheet-foot { padding: 10px 14px calc(12px + var(--safe-b)); }

  /* 卡片上的「看报告」按钮加大，方便拇指点 */
  .score-btn { padding: 7px 12px; min-height: 34px; }
  .score-num { font-size: 16px; }
  .score-cue { font-size: 11.5px; }
}

/* ============ 画面标注 ============ */

@media (max-width: 767px) {
  .mark { border-width: 2.5px; border-radius: 4px; }
  /* 触摸目标放大：框本身可能很小，靠序号与标签保证可点 */
  .mark-no {
    width: 22px; height: 22px; line-height: 22px;
    font-size: 12px; left: -10px; top: -10px;
  }
  .mark-tag {
    font-size: 11.5px; padding: 2px 8px; bottom: -22px;
    max-width: 120px; overflow: hidden; text-overflow: ellipsis;
  }

  .mark-tip {
    width:min(260px, 86%);
    font-size: 13.5px; padding: 12px 14px;
  }
  .mark-tip-title { font-size: 14.5px; }
  .mark-tip-t { font-size: 14px; line-height: 1.7; }

  .mark-switch { padding: 8px 12px 0; }
  .mark-toggle { padding: 8px 14px; min-height: 36px; }

  /* 浮层里的封面图要留出标注空间，标签不被裁掉 */
  .sheet-cover { padding-bottom: 0; }
}

/* 识画：相机取景框图标 */
.mi-art::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1.6px solid currentColor;
  border-radius: 3px;
}
.mi-art::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  border: 1.6px solid currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.mobile-nav a.is-on .mi-art::before {
  border-radius: 50% 3px 3px 3px;
}

/* ============ 老师寄语 ============ */

@media (max-width: 767px) {
  .teacher-note-b { font-size: 15px; line-height: 1.8; padding: 14px; }
  .teacher-note-h { font-size: 12.5px; }
}

/* ============ 发布页 ============ */

@media (max-width: 767px) {
  .panel { padding: 16px 14px; border-radius: 12px; }
  .panel-title { font-size: 15.5px; margin-bottom: 14px; }

  /* 上传预览改为三列，节省纵向空间 */
  .up-preview {
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
  }
  .up-del { width: 24px; height: 24px; font-size: 16px; line-height: 24px; }

  .field { margin-bottom: 13px; }
  .field-label { font-size: 12.5px; margin-bottom: 6px; }
  .field textarea { min-height: 96px; }

  /* 手机上双列字段太窄，改单列 */
  .grid-2-fields { grid-template-columns: 1fr; gap: 0; }

  .btn-primary { min-height: 46px; font-size: 15.5px; }
  .btn-line { min-height: 42px; }
  .switch-row { padding: 4px 0; }
}

/* ============ 个人中心 ============ */

@media (max-width: 767px) {
  .me-head { padding: 16px 14px; gap: 12px; }
  .me-name { font-size: 17px; }
  .me-bio { font-size: 13px; }

  /* 四格统计改两列两行，数字不会挤成一团 */
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    padding: 0;
    background: var(--line);
    overflow: hidden;
  }
  .stat { padding: 15px 10px; background: #fff; }
  .stat-v { font-size: 21px; }
  .stat-k { font-size: 12px; }

  .admin-entry { margin: 14px 0; }
  .admin-entry .btn-line { display: block; width: 100%; padding: 13px; font-size: 15px; }
}

/* ============ 评论 ============ */

@media (max-width: 767px) {
  .cmt { gap: 9px; padding: 13px 0; }
  .cmt-name { font-size: 13.5px; }
  .cmt-text { font-size: 15px; line-height: 1.7; }
  .cmt-del {
    /* 删评论按钮扩大触达区 */
    padding: 8px 4px;
    margin: -8px -4px;
  }

  /* 评论输入框吸底，方便随时留言 */
  .cmt-input {
    position: sticky;
    bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
    z-index: 30;
    background: #fff;
    padding: 10px 0;
    margin-top: 12px;
    box-shadow: 0 -2px 12px rgba(24, 40, 72, .08);
  }
  .cmt-input input {
    min-height: 42px;
    padding: 10px 16px;
  }
  .cmt-input .btn-primary {
    padding: 10px 18px;
    min-height: 42px;
    white-space: nowrap;
  }
}

/* ============ 登录弹层：手机上变底部抽屉 ============ */

@media (max-width: 767px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    max-width: none;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 22px 18px calc(22px + var(--safe-b));
    max-height: 90vh;
    max-height: 90dvh;
    animation: sheetUp .22s ease-out;
  }
  @keyframes sheetUp {
    from { transform: translateY(16px); opacity: .6; }
    to { transform: translateY(0); opacity: 1; }
  }
  .modal-close {
    right: 12px; top: 12px;
    width: 34px; height: 34px;
    font-size: 26px;
  }
  .modal-title { font-size: 18px; }
  .modal-sub { font-size: 13px; margin-bottom: 16px; }
  .seg { margin-bottom: 16px; }
  .seg-btn { padding: 10px; font-size: 13.5px; }
  .field input, .field textarea { padding: 12px 14px; }
  .field-row input { flex: 1; min-width: 0; }
  .btn-code { padding: 0 14px; font-size: 13px; }
}

/* ============ 图片查看器 / 吐司 ============ */

@media (max-width: 767px) {
  .viewer { padding: 12px; }
  .viewer-close {
    right: 10px; top: calc(10px + var(--safe-t));
    width: 40px; height: 40px;
    font-size: 24px;
    background: rgba(255, 255, 255, .2);
  }

  .toast {
    left: 50%;
    bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
    max-width: 86vw;
    font-size: 14px;
    padding: 11px 18px;
    /* 吐司必须压在标签栏之上 */
    z-index: 95;
  }
}

/* ============ 空态与加载 ============ */

@media (max-width: 767px) {
  .empty { padding: 52px 20px; }
  .empty-icon { font-size: 38px; }
  .empty-text { font-size: 14.5px; }
  .loading { padding: 34px 0; }
}

/* ============ 极窄屏兜底 ============ */

@media (max-width: 340px) {
  .app { padding: 10px 9px 20px; }
  .card-body { padding: 10px 11px 12px; }
  .dim-c { margin-left: 0; }
  .topbar { gap: 7px; }
  .brand-name { font-size: 15px; }
}

/* ============ 横屏微调 ============ */

@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .detail-stage .img { max-height: 72vh; }
  .modal-card { max-height: 94vh; padding: 16px 18px; }
}
