/* ============================================================
   丽泽AI古瓷图文比对 —— 前端样式
   移动端优先（mobile-first），≥600px 平板、≥960px 桌面渐进增强
   ============================================================ */

:root {
    --primary: #922b21;
    --primary-dark: #7a231b;
    --gold: #b8860b;
    --gold-dark: #8a6508;
    --amber-50: #fdf8ef;
    --amber-200: #f0dfc0;
    --stone-50: #f8f7f5;
    --stone-100: #f1efec;
    --stone-300: #d6d2cb;
    --text: #2d2a26;
    --text-sub: #6b6560;
    --text-light: #a09a92;
    --line: #e8e2d8;
    --danger: #b91c1c;
    --ok: #15803d;
    --radius: 10px;
    --shell-max: 640px;
}

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

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--stone-100);
    color: var(--text);
    line-height: 1.6;
}

/* 应用外壳：手机上占满全宽；平板/桌面居中呈卡片 */
.app-shell {
    max-width: var(--shell-max);
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: #fff;
    box-shadow: 0 0 24px rgba(0,0,0,.08);
    padding: 24px 20px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- 页面切换 ---------- */
.page { display: none; animation: fadeIn .25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 标题 ---------- */
.page-header { text-align: center; border-bottom: 1px solid var(--amber-200); padding-bottom: 16px; margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; color: var(--primary); }
.page-header .sub { font-size: .875rem; color: var(--text-sub); margin-top: 8px; }
.page-header .note { font-size: .75rem; color: var(--text-light); margin-top: 4px; text-align: justify; }

.page-title { font-size: 1.25rem; color: var(--primary); text-align: center; margin-bottom: 16px; }
.page-title.underlined { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px; }

/* ---------- 表单 ---------- */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 4px; }
.field input:not([type="checkbox"]) {
    width: 100%;
    border: 1px solid var(--stone-300);
    border-radius: 8px;
    padding: 12px;
    /* 16px 防 iOS 聚焦自动放大 */
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    min-height: 48px;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(146,43,33,.12); }
.field input[type="file"] { padding: 10px; font-size: .875rem; min-height: 0; }

/* ---------- 图片网格（自适应列数，支持删除/追加） ---------- */
.img-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}
@media (min-width: 480px) { .img-grid { grid-template-columns: repeat(4, 1fr); } }
.img-item { position: relative; }
.img-grid img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: block;
}
@media (min-width: 480px) { .img-grid img { height: 104px; } }
.img-del {
    position: absolute;
    top: 4px; right: 4px;
    width: 24px; height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,.65);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.img-del:active { background: rgba(0,0,0,.9); }

/* ---------- 已选照片大图预览（灯箱） ---------- */
.img-grid img { cursor: zoom-in; }
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.88);
    display: none;
    align-items: center; justify-content: center;
    z-index: 200;
}
.lightbox.show { display: flex; }
.lightbox img {
    max-width: 92vw;
    max-height: 84vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
    user-select: none;
}
.lightbox-btn {
    position: absolute;
    border: none;
    background: rgba(0,0,0,.55);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-btn:active { background: rgba(0,0,0,.85); }
.lightbox-close {
    top: 12px; right: 14px;
    width: 36px; height: 36px;
    font-size: 22px;
    line-height: 1;
}
.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 40px; height: 40px;
    font-size: 26px;
    line-height: 1;
}
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }
.lightbox-nav:disabled { opacity: .3; cursor: default; }
.lightbox-counter {
    position: absolute;
    left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    color: rgba(255,255,255,.85);
    font-size: .8125rem;
    margin: 0;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 13px 18px;
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: opacity .15s ease, transform .1s ease;
    min-height: 48px; /* 触控友好 */
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; border-color: var(--stone-300); color: var(--text); }
.btn-gold { background: #d97706; color: #fff; }
.btn-dark { background: #44403c; color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-lg { margin-top: 32px; }
.btn-sm { min-height: 40px; padding: 9px 14px; font-size: .8125rem; margin-top: 8px; }
.btn-row { display: flex; gap: 12px; margin-top: 32px; }
.flex-1 { flex: 1; }
.mt-gap { margin-top: 12px; }

/* ---------- 打分维度列表 ---------- */
.dim-list { display: flex; flex-direction: column; gap: 20px; font-size: .875rem; }
.dim-item .dim-name { font-weight: 600; }
.dim-item .dim-desc { font-size: .75rem; color: var(--text-sub); margin-top: 2px; }
.dim-item .dim-note { font-size: .75rem; color: var(--text-light); margin-top: 2px; }
.dim-range {
    display: inline-block;
    margin-left: 8px;
    font-size: .6875rem;
    font-weight: 400;
    color: var(--gold-dark);
    background: var(--amber-50);
    border: 1px solid var(--amber-200);
    border-radius: 10px;
    padding: 0 8px;
}

/* 星星打分：触控区域放大 */
.star-box { margin-top: 6px; display: flex; gap: 6px; }
.star {
    color: #ccc;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
    padding: 4px 2px; /* 扩大点击热区 */
    user-select: none;
}
.star.active { color: var(--gold); }

.warn-note { font-size: .75rem; color: var(--gold-dark); margin-bottom: 16px; text-align: center; }
.tip-note { font-size: .75rem; color: var(--text-sub); margin-top: 16px; }

/* AI 评分相关 */
.ai-note {
    font-size: .8125rem;
    background: var(--amber-50);
    border: 1px solid var(--amber-200);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    color: var(--text-sub);
}
.ai-status {
    text-align: center;
    font-size: .875rem;
    color: var(--gold-dark);
    font-weight: 600;
    margin: 16px 0;
    padding: 10px;
    background: var(--stone-50);
    border-radius: 8px;
}
.ai-status.ok { color: var(--ok); }
.ai-status.fail { color: var(--danger); }

.total-card {
    display: flex;
    align-items: baseline;
    gap: 12px;
    background: var(--stone-50);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 10px 0 12px;
    font-size: .8125rem;
    color: var(--text-sub);
}
.total-card b { font-size: 1.25rem; color: var(--primary); }

.score-extra {
    margin-top: 10px;
    font-size: .75rem;
    color: var(--text-sub);
    background: var(--stone-50);
    border-radius: 8px;
    padding: 8px 12px;
}
.score-extra-note {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
    color: var(--text-sub);
    line-height: 1.7;
}

/* ---------- 价格卡 / 提示框 ---------- */
.price-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 24px; text-align: center; }
.price-name { font-size: 1.125rem; }
.price-value { font-size: 2rem; color: var(--gold); font-weight: 700; margin-top: 8px; }
.price-note { font-size: .75rem; color: var(--text-light); margin-top: 8px; }

.alert { border-radius: 8px; padding: 12px; margin-bottom: 16px; font-size: .75rem; text-align: left; }
.alert-title { font-weight: 700; margin-bottom: 4px; }
.alert-red { background: var(--amber-50); border: 1px solid var(--line); color: var(--text-sub); }
.alert-red .alert-title { color: var(--danger); }
.alert-gold { background: var(--amber-50); border: 1px solid var(--amber-200); color: var(--text-sub); }
.alert-gold .alert-title { color: #92400e; }

.bank-card { background: var(--stone-50); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: .75rem; margin-bottom: 24px; }
.bank-card .alert-title { font-weight: 600; margin-bottom: 4px; }

.agree-row { display: flex; gap: 8px; align-items: flex-start; font-size: .75rem; margin-bottom: 16px; }
.agree-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); }

.center-text { font-size: .875rem; color: var(--text-sub); text-align: center; }

/* ---------- 报告页 ---------- */
.base-info { font-size: .875rem; display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.base-info .label { font-weight: 500; }

.section { margin-bottom: 16px; }
.section-title { font-size: 1rem; font-weight: 700; }
.score-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: .875rem; }
.score-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.score-bar { flex: 1; height: 6px; background: var(--stone-100); border-radius: 3px; overflow: hidden; }
.score-bar > i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.score-num { color: var(--text-sub); white-space: nowrap; }

.panel { border-radius: 8px; padding: 12px; margin-bottom: 16px; font-size: .75rem; }
.panel-title { font-weight: 700; margin-bottom: 6px; font-size: .875rem; }
.panel-gold { border: 1px solid var(--amber-200); background: var(--amber-50); }
.panel-gold .panel-title { color: var(--gold-dark); }
.panel-dark { border: 1px solid var(--stone-300); }
.panel-plain { border: 1px solid var(--line); }
.panel p { margin-top: 4px; }

.dot-list { list-style: disc; padding-left: 20px; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.num-list { list-style: decimal; padding-left: 20px; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.red-note { color: var(--danger); margin-top: 8px; }

.disclaimer { font-size: .75rem; color: var(--text-sub); border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- 订单列表 ---------- */
.order-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.order-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-type { font-weight: 500; }
.order-price { color: var(--gold); font-weight: 600; white-space: nowrap; }
.order-meta { font-size: .75rem; color: var(--text-sub); margin-top: 4px; word-break: break-all; }
.order-status { font-size: .75rem; color: var(--ok); margin-top: 4px; }
.order-status.pending { color: #d97706; }
.order-status.fail { color: var(--danger); }
.order-card .btn { margin-top: 8px; }
.order-empty { text-align: center; color: var(--text-light); font-size: .875rem; padding: 32px 0; }
.order-footnote { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 16px; font-size: .75rem; color: var(--text-sub); }

/* 照片张数计数器（须满 9 张） */
.img-count { margin-left: 6px; font-size: .75rem; color: var(--gold-dark); font-weight: 600; }
.img-count.ok { color: var(--ok); }

/* ---------- 我的订单：列表滚动、说明与按钮固定底部 ---------- */
/* 页面占满视口高度（扣除外壳上下内边距），三段式：标题 / 滚动列表 / 固定底部 */
#page8.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 56px - env(safe-area-inset-bottom));
}
#page8 .page-title { flex-shrink: 0; }
#page8 #orderList {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}
#page8 .order-footnote { flex-shrink: 0; margin-top: 12px; padding-top: 10px; margin-bottom: 10px; }
#page8 .btn-row { flex-shrink: 0; }

/* ---------- 关于页 ---------- */
.about-body { font-size: .875rem; display: flex; flex-direction: column; gap: 10px; }
.about-note { color: var(--primary); margin-top: 16px; }

/* ---------- 首页底部链接 ---------- */
.footer-links { margin-top: 24px; font-size: .75rem; color: var(--text-sub); border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.link-row a { cursor: pointer; text-decoration: underline; }
.link-primary { color: var(--primary); }
.link-gold { color: #92400e; }

/* ---------- Toast / Loading ---------- */
.toast {
    position: fixed;
    left: 50%; bottom: calc(80px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,.8);
    color: #fff;
    font-size: .875rem;
    padding: 10px 18px;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    transition: all .25s ease;
    max-width: 86vw;
    z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading-mask {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.6);
    display: none;
    align-items: center; justify-content: center;
    z-index: 99;
}
.loading-mask.show { display: flex; }
.loading-box {
    background: rgba(0,0,0,.75);
    color: #fff;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: .875rem;
}

/* ============================================================
   平板 ≥600px：适当加大留白与字号
   ============================================================ */
@media (min-width: 600px) {
    html { font-size: 17px; }
    .app-shell { padding: 32px 32px calc(40px + env(safe-area-inset-bottom)); }
    .page-header h1 { font-size: 1.75rem; }
    .page-title { font-size: 1.375rem; }
    .img-grid img { height: 120px; }
}

/* ============================================================
   桌面 ≥960px：居中卡片 + 背景纹理感
   ============================================================ */
@media (min-width: 960px) {
    body { padding: 24px 0; }
    .app-shell { border-radius: 16px; min-height: auto; }
}

/* ============================================================
   人工图鉴复核：进度展示与人工评分结果
   ============================================================ */
.order-locked-note { color: #9a7b3f; font-size: .75rem; margin: 4px 0 0; }
.progress-box { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.progress-steps { margin: 18px 0 12px; }
.progress-step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; position: relative; }
.progress-step:not(:last-child)::after {
    content: ''; position: absolute; left: 14px; top: 40px; bottom: -6px;
    width: 2px; background: #e5e7eb;
}
.progress-step .step-dot {
    flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; background: #eef0f2; color: #8a8f98;
    font-size: .8125rem; font-weight: 700; z-index: 1;
}
.progress-step.current .step-dot { background: #922b21; color: #fff; }
.progress-step.done .step-dot { background: #2e7d5b; color: #fff; }
.progress-step strong { display: block; font-size: .9rem; }
.progress-step small { display: block; color: #888; font-size: .75rem; margin-top: 2px; }
.progress-step.current strong { color: #922b21; }
.progress-result { background: #fbf6ec; border: 1px solid #eadfc6; border-radius: 8px; padding: 12px 14px; }
.progress-result p { margin: 4px 0; font-size: .8125rem; }
.review-total { font-size: .95rem; margin: 0 0 10px; }
.review-total strong { color: #922b21; font-size: 1.4rem; }
.review-score-list { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.review-score-item { font-size: .78rem; color: #555; }
.review-score-item b { color: #922b21; }
