/* 验货照片报告 手机版 */

:root {
  --accent: #1d5fbf;
  --accent-soft: #e5eefb;
  --ok: #0f766e;
  --ok-soft: #e1f3f1;
  --danger: #c62828;
  --danger-soft: #fbe9e9;
  --wait: #b45309;
  --wait-soft: #fdf1e1;
  --bg: #f2f3f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6b7280;
  --line: #e2e4ea;
  --field: #f6f7fa;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --radius: 14px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #5b9bff;
    --accent-soft: #1d2a40;
    --ok: #34c3b2;
    --ok-soft: #12302d;
    --danger: #ff6b6b;
    --danger-soft: #3a1c1c;
    --wait: #f0a64a;
    --wait-soft: #3a2a14;
    --bg: #0f1013;
    --card: #1c1d22;
    --text: #f2f2f5;
    --muted: #9aa0ab;
    --line: #2c2e35;
    --field: #24262c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.camera-open, body.viewer-open { overflow: hidden; }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.error { color: var(--danger); }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  padding: calc(var(--top) + 6px) 8px 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.topbar.home .topbar-title { font-size: 20px; }
.app-icon { width: 30px; height: 30px; border-radius: 8px; margin-left: 6px; }
.save-btn { padding: 7px 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; background: none; border-radius: 10px; color: var(--accent);
}
.icon-btn:active { background: var(--accent-soft); }
.icon-btn:disabled { opacity: .3; }

.section-nav {
  position: sticky; top: calc(var(--top) + 53px); z-index: 19;
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav button {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 4px 12px; font-size: 14px; color: var(--muted);
}

/* ------------------------------------------------------------ icons (inline SVG masks) */
.icon { display: inline-block; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; flex: none; }
.icon-back { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 4 7 12l8 8' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.icon-more { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='5' cy='12' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='19' cy='12' r='2'/%3E%3C/svg%3E"); }
.icon-undo { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7 4 12l5 5M4 12h10a6 6 0 0 1 0 12h-2' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' transform='translate(0 -3)'/%3E%3C/svg%3E"); }
.icon-gear { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 8.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7Zm8.5 5-1.9.5a7 7 0 0 1-.7 1.7l1 1.7-2 2-1.7-1a7 7 0 0 1-1.7.7l-.5 1.9h-2.8l-.5-1.9a7 7 0 0 1-1.7-.7l-1.7 1-2-2 1-1.7a7 7 0 0 1-.7-1.7l-1.9-.5v-2.8l1.9-.5a7 7 0 0 1 .7-1.7l-1-1.7 2-2 1.7 1a7 7 0 0 1 1.7-.7l.5-1.9h2.8l.5 1.9a7 7 0 0 1 1.7.7l1.7-1 2 2-1 1.7a7 7 0 0 1 .7 1.7l1.9.5Z' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.icon-camera { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 8h3l1.5-2.5h7L17 8h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='13' r='3.6' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.icon-photos { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='18' height='16' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m4 17 5-5 4 4 3-3 4 4' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='15.5' cy='8.5' r='1.6'/%3E%3C/svg%3E"); }
.icon-rotate { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 12a8 8 0 1 1-2.3-5.7M20 4v5h-5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.icon-move { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12h14m-5-5 5 5-5 5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.icon-download { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4v11m-5-5 5 5 5-5M5 20h14' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.icon-trash { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 7h16M9 7V4h6v3m-9 0 1 13h10l1-13' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 0;
  font-weight: 600; background: var(--field); color: var(--text);
}
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.plain { background: var(--accent-soft); color: var(--accent); }
.btn.link { background: none; color: var(--accent); font-weight: 500; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 15px; }
.btn.big { width: 100%; min-height: 54px; font-size: 18px; border-radius: 14px; }

/* ------------------------------------------------------------ layout */
.home-main, .editor, .settings { padding: 12px 12px calc(var(--bottom) + 96px); max-width: 760px; margin: 0 auto; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 16px; margin: 0 0 12px; scroll-margin-top: calc(var(--top) + 110px);
}
.card-title { font-size: 17px; margin: 0 0 10px; }
.card-hint { color: var(--muted); font-size: 13px; margin: -4px 0 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.center-view { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }

.empty-hint { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0 16px; }
.page-end { color: var(--muted); font-size: 13px; text-align: center; padding: 12px 8px; }

/* ------------------------------------------------------------ fields */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; flex: 1; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 13px; color: var(--muted); }
.field-input {
  width: 100%; min-height: 42px; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field); color: var(--text);
  font: inherit; font-size: 16px; /* 16px: iPhone does not zoom into the field */
  -webkit-appearance: none; appearance: none;
}
select.field-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%236b7280' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 18px; padding-right: 30px;
}
.field-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--card); }
.field-input.number { text-align: center; }
.field-input.area { resize: vertical; min-height: 42px; line-height: 1.4; }
.field-status { font-size: 13px; color: var(--muted); min-height: 0; }
.field-status.error { color: var(--danger); }
.field-hint { font-size: 13px; color: var(--muted); display: block; }
.field-row { display: flex; gap: 10px; }
.field-row > .field { margin-bottom: 12px; }
.inline { display: flex; gap: 8px; }
.inline .btn { flex: none; white-space: nowrap; }

/* ------------------------------------------------------------ products */
.product-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.product-code { font-weight: 700; font-size: 17px; word-break: break-all; }
.product-name { color: var(--muted); font-size: 14px; }
.product-fields { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.sample-value { min-height: 42px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; background: var(--bg); border-radius: 10px; }
.defects { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.defect { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); text-align: center; }
.judge-row { display: flex; gap: 8px; align-items: center; }
.judge { flex: 1; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); font-weight: 600; }
.judge.pass.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.judge.fail.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.judge-mode { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 4px; white-space: nowrap; }
.judge-mode:disabled { color: var(--muted); }
.judge-basis { font-size: 12px; color: var(--muted); margin-top: 4px; }
.add-product { width: 100%; min-height: 50px; margin-bottom: 12px; background: var(--card); color: var(--accent); border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); }

/* ------------------------------------------------------------ photo windows */
.win-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.win-title { font-weight: 600; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.win-count { color: var(--muted); font-size: 13px; font-weight: 400; }
.win-tools { display: flex; gap: 6px; flex: none; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 4px 10px;
  border-radius: 999px; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600;
}
.tool-btn .icon { width: 18px; height: 18px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; min-height: 40px; position: relative; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* the camera frame: the whole window while it is empty, the last tile after the photos */
.shoot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  aspect-ratio: 3 / 4; margin-bottom: 26px; padding: 6px; border-radius: 10px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.shoot:active { filter: brightness(.95); }
.shoot .icon { width: 30px; height: 30px; }
.shoot-hint { display: none; font-size: 13px; font-weight: 400; color: var(--muted); }
.grid.is-empty .shoot { grid-column: 1 / -1; aspect-ratio: auto; min-height: 150px; margin-bottom: 0; }
.grid.is-empty .shoot .icon { width: 40px; height: 40px; }
.grid.is-empty .shoot-label { font-size: 17px; }
.grid.is-empty .shoot-hint { display: block; text-align: center; }
body.jiggling .shoot { opacity: .5; }

.cell { min-width: 0; position: relative; }
.cell.appear .photo { animation: pop .28s cubic-bezier(.2,.9,.3,1.3); }
.cell.vanish { transition: transform .18s ease, opacity .18s ease; transform: scale(.4); opacity: 0; }
.cell.placeholder .photo { visibility: hidden; }
.cell.placeholder .caption { visibility: hidden; }
.cell.placeholder::before { content: ""; position: absolute; inset: 0 0 26px; border: 2px dashed color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 10px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.photo {
  position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: visible; background: #fff;
  box-shadow: 0 0 0 1px var(--line);
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; pointer-events: none; }
.badge {
  position: absolute; left: 5px; bottom: 5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 20px; text-align: center; pointer-events: none;
}
.remove {
  position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--card);
  background: rgba(60, 60, 67, .85); color: #fff; font-size: 18px; line-height: 20px; padding: 0; z-index: 2;
}
.remove::after { content: ""; position: absolute; inset: -9px; }   /* larger touch area */
.caption {
  margin-top: 4px; font-size: 12px; line-height: 1.3; min-height: 22px; padding: 2px 4px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.caption.placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.caption:active { background: var(--field); }
.caption-input { width: 100%; font-size: 16px; padding: 2px 4px; border: 1px solid var(--accent); border-radius: 6px; background: var(--card); color: var(--text); }

body.jiggling .photo { animation: wiggle .26s ease-in-out infinite alternate; animation-delay: var(--wiggle-delay, 0s); touch-action: none; }
body.jiggling .cell.placeholder .photo { animation: none; }
@keyframes wiggle { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }

.photo.lifted {
  position: fixed; left: 0; top: 0; z-index: 60; margin: 0; pointer-events: none; transform-origin: center;
  box-shadow: 0 16px 36px rgba(0,0,0,.28); animation: none;
}
.photo.lifted .remove { display: none; }

.jiggle-done {
  position: fixed; left: 50%; bottom: calc(var(--bottom) + 18px); transform: translateX(-50%); z-index: 40;
  min-height: 44px; padding: 8px 28px; border-radius: 999px; border: 0; background: var(--text); color: var(--card); font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* ------------------------------------------------------------ inspection table */
.check-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 10px; }
.field-input.category { font-weight: 600; margin-bottom: 6px; background: var(--bg); }
.check-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-top: 1px dashed var(--line); }
.check-row:first-of-type { border-top: 0; }
.check-line { display: flex; gap: 6px; align-items: flex-start; }
.check-line.two { display: grid; grid-template-columns: 1fr 96px; }
.field-input.area.autogrow { resize: none; overflow: hidden; min-height: 42px; }
.field-input.area.autogrow.comment { min-height: 110px; }
.more-btn { flex: none; width: 40px; min-height: 42px; border: 0; border-radius: 10px; background: var(--field); font-weight: 700; color: var(--muted); }

/* ------------------------------------------------------------ home lists */
.list-title { font-size: 15px; color: var(--muted); font-weight: 600; margin: 22px 4px 8px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list:has(> .empty-hint) { background: none; box-shadow: none; }
.row { display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:active { background: var(--field); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-sub.error { color: var(--danger); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--field); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.error { background: var(--danger-soft); color: var(--danger); }
.chip.wait { background: var(--wait-soft); color: var(--wait); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chips .chip { font-size: 14px; padding: 4px 6px 4px 10px; color: var(--text); }
.chip-x { border: 0; background: none; font-size: 16px; padding: 0 4px; color: var(--muted); }

.banner { background: var(--accent-soft); color: var(--text); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.banner.error { background: var(--danger-soft); }
.banner.install p { margin: 6px 0; }
.banner .btn { margin-top: 4px; }
.icp { text-align: center; margin-top: 28px; font-size: 12px; }
.icp a { color: var(--muted); text-decoration: none; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.switch-label { display: block; }
.switch-row input { width: 46px; height: 28px; flex: none; accent-color: var(--accent); }
.selftest { background: var(--field); border-radius: 10px; padding: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

/* ------------------------------------------------------------ sheets & toasts */
/* dialogs above everything else: camera (70), progress (95) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .2s; z-index: 96; }
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 97; max-height: 88vh; overflow: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(var(--bottom) + 14px);
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  max-width: 640px; margin: 0 auto;
}
.sheet.show { transform: none; }
.sheet-title { font-weight: 700; font-size: 17px; margin-bottom: 10px; text-align: center; }
.sheet-text { white-space: pre-wrap; margin: 0 0 12px; }
.sheet-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sheet-buttons .btn { width: 100%; }
.sheet.actions .sheet-buttons { gap: 0; }
.sheet.actions .btn { border-radius: 0; background: none; border-top: 1px solid var(--line); color: var(--accent); font-weight: 500; }
.sheet.actions .btn.danger-text { color: var(--danger); }
.sheet.actions .btn.cancel { margin-top: 8px; border-radius: 12px; background: var(--field); border: 0; font-weight: 600; color: var(--text); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--bottom) + 24px); z-index: 100; transform: translateY(20px);
  width: fit-content; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: rgba(30, 30, 34, .94); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 15px;
  opacity: 0; transition: opacity .2s, transform .2s; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: none; }
.toast span { flex: 1; }
body.viewer-open .toast { bottom: calc(var(--bottom) + 150px); }
.toast.error { background: #8e1f1f; }
.toast-action { border: 0; background: none; color: #8fb8ff; font-weight: 700; padding: 4px; white-space: nowrap; }
body.jiggling .toast { bottom: calc(var(--bottom) + 76px); }

.progress-overlay { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 24px; }
.progress-box { background: var(--card); border-radius: 16px; padding: 22px; width: min(320px, 100%); text-align: center; }
.progress-title { font-weight: 700; margin: 10px 0 6px; }
.progress-label { font-size: 14px; color: var(--muted); min-height: 20px; }
.progress-bar { height: 6px; background: var(--field); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress-bar.indeterminate .progress-fill { width: 30%; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { text-align: center; }
.result-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 30px; line-height: 52px; margin: 0 auto 8px; }
.result-text { font-weight: 600; margin: 4px 0; }
.result-file { word-break: break-all; margin: 4px 0; }
.result-detail { color: var(--muted); font-size: 14px; margin: 4px 0; }
.result-mail { font-size: 14px; margin: 10px 0 4px; color: var(--muted); }
.result-mail.ok { color: var(--ok); font-weight: 600; }
.result-mail.error { color: var(--danger); }
.result-mail.wait { color: var(--wait); }

.update-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--bottom) + 12px); z-index: 80;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--text); color: var(--card); border-radius: 14px; padding: 10px 12px 10px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* ------------------------------------------------------------ camera */
.camera { position: fixed; inset: 0; z-index: 70; background: #000; color: #fff; display: flex; flex-direction: column; --icon-turn: 0deg; }
.cam-top { display: flex; align-items: center; gap: 8px; padding: calc(var(--top) + 6px) 10px 6px; }
.cam-title { flex: 1; text-align: center; font-size: 15px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-close, .cam-torch { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 20px; }
.cam-torch.on { background: #ffd60a; color: #000; }
.cam-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.cam-frame { position: relative; width: 100%; max-height: 100%; aspect-ratio: 3 / 4; overflow: hidden; }
.cam-frame.landscape { width: auto; height: 100%; max-width: 100%; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-grid { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.25) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255,255,255,.25) 0 calc(66.66% + .5px), transparent 0),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.25) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255,255,255,.25) 0 calc(66.66% + .5px), transparent 0); }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .25s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.cam-message { position: absolute; left: 24px; right: 24px; top: 40%; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.cam-message p { margin: 0; }
.cam-bottom { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px calc(var(--bottom) + 22px); }
.cam-last { width: 52px; height: 52px; border-radius: 10px; background: rgba(255,255,255,.12) center / cover no-repeat; position: relative; transform: rotate(var(--icon-turn)); transition: transform .3s; }
.cam-count { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); font-size: 13px; line-height: 22px; text-align: center; padding: 0 5px; display: none; }
.cam-last.has .cam-count { display: block; }
.cam-shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: #fff; box-shadow: inset 0 0 0 3px #000; }
.cam-shutter:active { transform: scale(.94); }
.cam-shutter:disabled { opacity: .5; }
.cam-done { min-width: 64px; height: 44px; border: 0; border-radius: 22px; background: #ffd60a; color: #000; font-weight: 700; padding: 0 16px; transform: rotate(var(--icon-turn)); transition: transform .3s; }
.cam-turned { position: absolute; left: 50%; top: calc(var(--top) + 64px); transform: translateX(-50%); font-size: 12px; background: rgba(0,0,0,.5); padding: 3px 10px; border-radius: 999px; }

/* ------------------------------------------------------------ viewer & preview */
.viewer, .preview { position: fixed; inset: 0; z-index: 65; background: #0b0b0d; color: #fff; display: flex; flex-direction: column; }
.preview { background: var(--bg); color: var(--text); }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: calc(var(--top) + 8px) 12px 8px; }
.viewer-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-counter { font-size: 14px; opacity: .7; }
.viewer-close { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 17px; padding: 8px; }
.viewer .viewer-close { color: #8fb8ff; }
.viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y pinch-zoom; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.viewer-img.slide-left { animation: from-right .22s ease-out; }
.viewer-img.slide-right { animation: from-left .22s ease-out; }
@keyframes from-right { from { transform: translateX(40px); opacity: .3; } }
@keyframes from-left { from { transform: translateX(-40px); opacity: .3; } }
.viewer-bottom { padding: 10px 12px calc(var(--bottom) + 10px); display: flex; flex-direction: column; gap: 10px; }
.viewer-caption { width: 100%; min-height: 42px; border-radius: 10px; border: 1px solid #3a3a40; background: #1c1c20; color: #fff; padding: 8px 12px; font-size: 16px; }
.viewer-tools { display: flex; justify-content: space-around; }
.viewer-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; color: #fff; font-size: 12px; min-width: 60px; padding: 4px; }

.preview-info { padding: 0 16px 8px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.preview-info .warn { color: var(--danger); }
.preview-body { flex: 1; overflow: auto; padding: 0 12px calc(var(--bottom) + 20px); }
.preview-loading, .preview-error { text-align: center; padding: 40px 12px; }
.preview-error { color: var(--danger); }
.preview-svg { width: 100%; height: auto; display: block; background: #fff; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.pv-page { fill: #fff; }
.pv-section { fill: none; stroke: #c9d6ee; stroke-width: 2000; }
.pv-section.pv-defect { stroke: #f2c4c4; }
.pv-section.pv-other { stroke: #cfe7e3; }
.pv-title { fill: #1d5fbf; }
.pv-box { fill: #f3f4f6; stroke: #bfbfbf; stroke-width: 3175; }
.pv-caption { fill: #333; }
.pv-empty { fill: #f6f7f9; }
.pv-empty-text { fill: #9aa0ab; }
.pv-break { stroke: #c62828; stroke-width: 6000; stroke-dasharray: 40000 30000; }
.pv-break-text { fill: #c62828; }
