:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #1f2328;
    --muted: #6b7280;
    --line: #e3e6ea;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --ok: #15803d;
    --ok-bg: #f0fdf4;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

header.topbar {
    background: #111827;
    color: #fff;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

header.topbar .brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    padding: 12px 0;
    margin-right: 8px;
}

header.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }

header.topbar nav a {
    color: #d1d5db;
    text-decoration: none;
    padding: 12px 14px;
    border-bottom: 2px solid transparent;
}

header.topbar nav a:hover { color: #fff; background: #1f2937; }
header.topbar nav a.active { color: #fff; border-bottom-color: var(--brand); }

header.topbar .me { margin-left: auto; display: flex; align-items: center; gap: 12px; }
header.topbar .me a { color: #d1d5db; text-decoration: none; }
header.topbar .me a:hover { color: #fff; }
header.topbar form.logout button {
    background: none;
    border: 0;
    color: #9ca3af;
    font: inherit;
    cursor: pointer;
    padding: 12px 0;
}
header.topbar form.logout button:hover { color: #fff; }

main.login { max-width: 360px; padding-top: 12vh; }
main.login h1 { margin-bottom: 16px; }
main.login label.check { display: flex; align-items: center; gap: 6px; font-weight: normal; margin-bottom: 14px; }
main.login .btn { width: 100%; padding: 8px 14px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 18px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
}

.panel > h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat.danger .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f9fafb; font-weight: 600; color: #374151; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafbfc; }
tfoot td { font-weight: 700; background: #f9fafb; }

.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.muted { background: #f3f4f6; color: var(--muted); }

.btn {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}

.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.sm { padding: 3px 10px; font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .right { display: flex; gap: 8px; align-items: center; }

form .field { margin-bottom: 12px; }
form label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd2d9;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
input.inline { width: 110px; padding: 4px 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.alert.error { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert.warn { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.alert.ok { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.empty { color: var(--muted); padding: 18px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ---------- 手機版 ---------- */
@media (max-width: 640px) {
    main { padding: 12px; }
    h1 { font-size: 18px; }

    /* 導覽列：單行可橫滑，不折行 */
    header.topbar { padding: 0 12px; gap: 10px; flex-wrap: nowrap; }
    header.topbar .brand { padding: 10px 0; font-size: 15px; white-space: nowrap; }
    header.topbar nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    header.topbar nav::-webkit-scrollbar { display: none; }
    header.topbar nav a { padding: 10px 10px; white-space: nowrap; font-size: 14px; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .right { flex-wrap: wrap; }
    .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat .value { font-size: 20px; }
    .form-grid { grid-template-columns: 1fr; }
    input.inline { width: 100%; }

    /* 表格變卡片：每列一張，欄名由 data-label 帶出來（common.html 的 script 會填） */
    table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
    table.cards thead { display: none; }
    table.cards tbody tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 6px 12px;
        background: #fff;
    }
    table.cards tbody tr:hover { background: #fff; }
    table.cards td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        padding: 5px 0;
        border-bottom: 1px dashed var(--line);
        text-align: right;
    }
    table.cards td:last-child { border-bottom: none; }
    table.cards td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        flex: 0 0 auto;
        text-align: left;
    }
    table.cards td[data-label=""]::before { content: none; }
    table.cards td.card-empty { display: none; }
    table.cards td.card-title {
        justify-content: flex-start;
        font-size: 16px;
        border-bottom: 1px solid var(--line);
        padding-bottom: 8px;
        margin-bottom: 2px;
    }
    table.cards td.card-title::before { content: none; }
    table.cards td.card-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 10px;
    }
    table.cards td.card-actions::before { content: none; }
    table.cards td.card-actions form { display: inline; }
    table.cards td.card-actions .btn { margin: 0; }
    table.cards tfoot { display: block; }
    table.cards tfoot tr { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 12px; }
    table.cards tfoot td { display: inline; padding: 0; border: none; width: auto; }
    table.cards tfoot td:empty { display: none; }
    table.cards td input[type=text], table.cards td select { width: 60%; }
    table.cards td input.inline { width: 110px; }
}

/* 照片（fragments/attachments.html） */
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photo-upload { border: 2px dashed var(--line); border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.photo-upload.drag { border-color: var(--brand); background: #eff6ff; }
.photo-upload.busy { opacity: .6; pointer-events: none; }
.photo-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.photo-buttons label.btn { display: inline-block; position: relative; margin: 0; font-weight: 600; }
.photo-buttons .photo-note { flex: 1; min-width: 180px; width: auto; }
.photo-status:not(:empty) { margin-top: 8px; color: var(--muted); }
.photo-status.error { color: var(--danger); }
.drop-hint { margin-top: 6px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.photo-grid.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 6px; }
.photo-card { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.photo-card > a { display: block; position: relative; aspect-ratio: 1; background: #f3f4f6; }
.photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-card .photo-role { position: absolute; top: 6px; left: 6px; box-shadow: 0 0 0 1px #fff; }
.photo-card figcaption { padding: 6px 8px 8px; }
.photo-note-form { display: flex; gap: 4px; }
.photo-note-form input.inline { flex: 1; width: auto; min-width: 0; }
.photo-actions { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin-top: 4px; }
.photo-actions select { width: auto; padding: 3px 6px; font-size: 13px; }
/* 「拍照」只給手機（有觸控、沒滑鼠）；「拖進框」只給電腦 */
@media (hover: hover) and (pointer: fine) { .only-touch { display: none !important; } }
@media not all and (hover: hover) and (pointer: fine) { .only-mouse { display: none !important; } }
@media (max-width: 640px) {
    .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .photo-buttons label.btn { flex: 1; text-align: center; padding: 10px; font-size: 15px; }
    .photo-buttons .photo-note { flex-basis: 100%; }
}

/* ---------- 家中物品 ---------- */
main.narrow { max-width: 860px; }
a { color: var(--brand); }
.spacer { flex: 1; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: normal; }
label.check input { width: auto; }

/* 首頁搜尋：手機上最常用的就是這一格，做大 */
form.search { display: flex; gap: 8px; margin-bottom: 18px; }
form.search input[type=search] {
    flex: 1; font-size: 17px; padding: 11px 14px; border: 1px solid #cbd2d9; border-radius: 8px; min-width: 0;
}
form.search input[type=search]:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
form.search .btn { font-size: 16px; padding: 0 18px; }
.empty-result { text-align: center; padding: 24px 16px; }
.empty-result p { margin: 0 0 8px; }

.shortcuts { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
a.stat.link { text-decoration: none; color: inherit; }
a.stat.link:hover { border-color: var(--brand); }

/* 物品清單（fragments/items.html） */
ul.item-list { list-style: none; margin: 0; padding: 0; }
ul.item-list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.item-list li:last-child { border-bottom: 0; }
ul.item-list .thumb {
    flex: 0 0 56px; width: 56px; height: 56px; border-radius: 6px; overflow: hidden; position: relative;
    background: #eef2f7; display: flex; align-items: center; justify-content: center; text-decoration: none;
}
ul.item-list .thumb img { width: 100%; height: 100%; object-fit: cover; }
ul.item-list .thumb-empty { font-size: 22px; color: #94a3b8; font-weight: 700; }
ul.item-list .thumb-tag {
    position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center;
    background: rgba(17, 24, 39, .6); color: #fff; line-height: 1.5;
}
ul.item-list .info { flex: 1; min-width: 0; }
ul.item-list .name { font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
ul.item-list .path { display: block; color: var(--brand); text-decoration: none; font-size: 13px; }
ul.item-list .row-actions { display: flex; gap: 4px; flex: 0 0 auto; }

/* 位置樹、麵包屑 */
ul.tree { list-style: none; margin: 0 0 10px; padding: 0; }
ul.tree li { padding: 7px 8px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
ul.tree li:last-child { border-bottom: 0; }
ul.tree li.root > a { font-weight: 700; }
ul.tree li.just-added { background: var(--ok-bg); }
ul.tree a { text-decoration: none; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.crumbs a { text-decoration: none; }
.crumbs .sep { color: var(--muted); }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input[type=text], .inline-form input[type=password] { flex: 1; min-width: 0; }
.inline-form.grow { flex: 1; }
.inline-form input.sort { width: 80px; flex: 0 0 80px; }
.manage-list { margin-top: 12px; display: grid; gap: 6px; }
details.panel > summary { cursor: pointer; }

/* 物品頁 */
.toolbar .right form { display: inline-flex; gap: 4px; }
.restock input[type=number] { width: 64px; }
.similar { margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: var(--warn-bg); border: 1px solid #fde68a; }
.similar a { display: block; color: #92400e; text-decoration: none; padding: 2px 0; }
.similar a:hover { text-decoration: underline; }
.panel.meta div { margin-bottom: 2px; }

/* 盤點 */
ul.codes { list-style: none; padding: 0; margin: 0; }
ul.codes li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
ul.codes code { font-size: 13px; word-break: break-all; }

/* 家人帳號 */
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.user-row:last-child { border-bottom: 0; }
.user-row.disabled .who { opacity: .55; }
.user-row .who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.user-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.user-actions input[type=password] { width: 120px; }

@media (max-width: 640px) {
    header.topbar .me { gap: 8px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
    header.topbar .me form.logout button { white-space: nowrap; }
    .shortcuts { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .shortcuts .stat { padding: 10px; }
    .shortcuts .label { font-size: 12px; }
    ul.item-list .thumb { flex-basis: 48px; width: 48px; height: 48px; }
    .toolbar .right { justify-content: flex-start; }
    .user-actions { width: 100%; }
}

/* AI 辨識（recognize.html） */
.ai-form { margin: 6px 0 2px; }
.ai-form .btn { width: 100%; }
.recognize-head { display: flex; gap: 14px; align-items: flex-start; }
.recognize-head img { width: 90px; height: 90px; object-fit: cover; border-radius: 6px; display: block; }
.recognize-head p { margin: 0 0 6px; }
.panel.detected { padding: 12px 14px; }
.panel.detected .pick { margin-bottom: 8px; font-weight: 600; }
.panel.detected .field { margin-bottom: 8px; }
.btn.big { width: 100%; padding: 12px; font-size: 16px; margin-bottom: 30px; }
@media (max-width: 640px) {
    .recognize-head { flex-direction: column; }
    .recognize-head img { width: 30vw; height: 30vw; }
}

/* 多張照片一起辨識、用量頁 */
.ai-bar { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; padding: 10px 12px; border-radius: 8px; background: #eff6ff; border: 1px solid #bfdbfe; }
.ai-bar .btn { width: 100%; padding: 9px; font-size: 15px; }
.ai-bar .btn:disabled { opacity: .55; cursor: not-allowed; }
.photo-card .ai-pick { margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--brand); }
.recognize-photos { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 0 auto; max-width: 300px; }
.recognize-photos img { width: 90px; height: 90px; }
.usage-stats { grid-template-columns: repeat(2, 1fr); margin-bottom: 18px; }
@media (max-width: 640px) {
    .recognize-photos { max-width: none; }
    .recognize-photos img { width: 30vw; height: 30vw; }
}

/* 模型比較（compare.html） */
.ai-bar .compare-btn { background: #fff; }
.compare-head { display: flex; gap: 14px; align-items: flex-start; }
.compare-head p { margin: 0 0 6px; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.compare-col h2 { font-size: 15px; }
ol.detected-list { margin: 0; padding-left: 22px; }
ol.detected-list li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
ol.detected-list li:last-child { border-bottom: 0; }
@media (max-width: 900px) {
    .compare-grid { grid-template-columns: 1fr; }
    .compare-head { flex-direction: column; }
}

/* 兩種 AI 用法（整個抽屜 / 一樣一樣拍）、確認頁每列的照片 */
.ai-mode { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; border-bottom: 1px dashed #bfdbfe; }
.ai-mode-title { font-weight: 700; color: var(--ink); }
.ai-row { display: flex; gap: 6px; }
.ai-row select { width: auto; flex: 0 0 auto; }
.ai-row .btn { flex: 1; }
.panel.detected.with-photo { display: grid; grid-template-columns: 110px 1fr; gap: 0 14px; }
.panel.detected.with-photo > :not(.detected-photo) { grid-column: 2; }
.detected-photo { grid-row: 1 / span 6; grid-column: 1; }
.detected-photo img { width: 110px; height: 110px; object-fit: cover; border-radius: 6px; display: block; }
@media (max-width: 640px) {
    .ai-row { flex-direction: column; }
    .ai-row select { width: 100%; }
    .panel.detected.with-photo { grid-template-columns: 80px 1fr; gap: 0 10px; }
    .detected-photo img { width: 80px; height: 80px; }
}
.ai-bar input.ai-hint { width: 100%; }

/* 確認頁：照片上框出每樣東西、每列的截圖 */
.annotated { margin-bottom: 14px; }
.annotated > p { margin: 4px 0 0; }
.annot-photo { position: relative; margin: 0 0 10px; max-width: 900px; line-height: 0; }
.annot-photo img { width: 100%; height: auto; display: block; border-radius: 8px; }
.annot-photo figcaption { line-height: 1.6; }
.annot-photo .box {
    position: absolute; border: 2px solid #f59e0b; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
    text-decoration: none; line-height: 1;
}
.annot-photo .box span {
    position: absolute; left: -2px; top: -2px; transform: translateY(-100%);
    background: #f59e0b; color: #111; font-size: 12px; font-weight: 700; padding: 2px 5px; border-radius: 3px 3px 0 0;
}
.annot-photo .box.hl, .annot-photo .box.flash { border-color: #2563eb; z-index: 2; }
.annot-photo .box.hl span, .annot-photo .box.flash span { background: #2563eb; color: #fff; }
.box.flash, .panel.detected.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 6px rgba(37, 99, 235, .6); } 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); } }
.crop-link { position: relative; display: block; }
canvas.crop { width: 110px; height: 110px; border-radius: 6px; display: block; background: #f3f4f6; }
.crop-no {
    position: absolute; left: 4px; top: 4px; background: #f59e0b; color: #111; font-size: 12px; font-weight: 700;
    padding: 1px 6px; border-radius: 3px; line-height: 1.4;
}
@media (max-width: 640px) {
    canvas.crop { width: 80px; height: 80px; }
    .annot-photo .box span { font-size: 11px; padding: 1px 4px; }
}
.compare-pick summary { cursor: pointer; color: var(--muted); }
.compare-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 10px; margin: 6px 0; }
.compare-pick .btn { width: 100%; margin-top: 6px; }

/* AI 幫忙找、補別名 */
.ai-search { margin: 10px 0 14px; }
.ai-search-more { margin: -8px 0 18px; text-align: right; }
.ai-match, .alias-change { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.ai-match:last-child, .alias-change:last-child { border-bottom: 0; }
.ai-match ul.item-list li, .alias-change ul.item-list li { border-bottom: 0; padding-bottom: 2px; }
.ai-reason { color: #92400e; background: var(--warn-bg); border-radius: 6px; padding: 4px 8px; }
.alias-change .badge { margin-right: 4px; }

/* 首頁「這週該拍」 */
.due-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
a.due-card {
    display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit;
    border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
a.due-card:hover { border-color: var(--brand); }
.due-thumb {
    flex: 0 0 72px; width: 72px; height: 72px; border-radius: 6px; overflow: hidden;
    background: #eef2f7; display: flex; align-items: center; justify-content: center;
}
.due-thumb img { width: 100%; height: 100%; object-fit: cover; }
.due-thumb .thumb-empty { font-size: 24px; color: #94a3b8; font-weight: 700; }
.due-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.45; }
.due-path { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 重拍盤點確認頁（recheck.html）：綠框 = 還在、橘框 = 新出現的 */
.annot-photo .box.seen { border-color: #16a34a; }
.annot-photo .box.seen span, .crop-no.seen { background: #16a34a; color: #fff; }
.legend { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 2px solid #f59e0b; vertical-align: -1px; margin-left: 6px; }
.legend.seen { border-color: #16a34a; }
h2.recheck-section { margin: 22px 0 6px; padding-left: 10px; border-left: 5px solid var(--muted); }
h2.recheck-section.seen { border-color: #16a34a; }
h2.recheck-section.new { border-color: #f59e0b; }
h2.recheck-section.missing { border-color: var(--danger); }
.recheck-row { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.pair { display: flex; gap: 8px; }
.pair figure { margin: 0; text-align: center; }
.pair figcaption { font-size: 12px; color: var(--muted); }
.pair img, .pair .pair-empty {
    width: 110px; height: 110px; object-fit: cover; border-radius: 6px; display: flex;
    align-items: center; justify-content: center; background: #f3f4f6; color: #94a3b8; font-size: 12px; text-align: center;
}
.recheck-info .name { font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
.recheck-info .pick { margin: 6px 0 4px; font-weight: 600; }
.inline-qty { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.inline-qty input { width: 80px; }
.warn-text { color: var(--warn); }
.missing-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0; }
.missing-row .move-to { margin: 4px 0; }
.missing-row [hidden] { display: none; }   /* label.check 是 flex，會蓋過 hidden */
.missing-row .confirm-delete { color: var(--danger); font-weight: 600; }
.same-as select { width: 100%; }
@media (max-width: 640px) {
    .recheck-row { grid-template-columns: 1fr; }
    .pair img, .pair .pair-empty, .pair canvas.crop { width: 40vw; height: 40vw; }
}

/* 位置選單打字找（picker.js） */
input.picker-filter { width: 100%; margin-bottom: 4px; }

/* 貼紙：位置頁的貼紙列表、印貼紙頁 */
ul.label-list { list-style: none; margin: 0; padding: 0; }
ul.label-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.label-list li:last-child { border-bottom: 0; }
ul.label-list li.void { opacity: .5; }
ul.label-list form { display: inline; }
#labels > [data-label-scan] { margin-bottom: 8px; }
details.unbind { display: inline-block; }
details.unbind > summary { list-style: none; cursor: pointer; }
details.unbind > summary::-webkit-details-marker { display: none; }
details.unbind[open] { display: block; flex-basis: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
details.unbind form { display: block; margin-top: 6px; }
details.unbind [hidden] { display: none; }
/* 掃貼紙綁到這裡（label-bind.js） */
.scan-dialog { border: 0; border-radius: 10px; padding: 14px; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.scan-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.scan-dialog video { display: block; width: 100%; max-height: 55vh; object-fit: cover; border-radius: 8px; background: #000; }
.scan-dialog .scan-result { font-size: 15px; line-height: 1.5; }
.scan-dialog .scan-target { margin: 0 0 8px; font-size: 15px; }
.scan-dialog .scan-ok { margin: 4px 0; padding: 12px; border-radius: 8px; background: #dcfce7; color: #166534; font-size: 18px; line-height: 1.5; }
.scan-dialog .scan-next { margin: 12px 0 4px; }
.scan-dialog .scan-next-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.scan-dialog .scan-next-list .btn { min-width: 72px; padding: 12px 16px; font-size: 17px; font-weight: 600; }
.scan-dialog [hidden] { display: none !important; }
/* 掃到還沒綁的貼紙 → 選位置（label-scan.html、label-choose.js） */
.chooser .next-bind { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chooser .next-bind > div { flex-basis: 100%; }
.chooser label.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; padding: 12px 16px;
                      border: 1px solid var(--line); border-radius: 10px; font-size: 17px; font-weight: 600; cursor: pointer; }
.chooser input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.chooser .chooser-filter { margin-bottom: 8px; }
.chooser details.tree-group { border-top: 1px solid var(--line); }
.chooser details.tree-group > summary { padding: 10px 4px; font-weight: 700; cursor: pointer; }
.chooser label.loc-row { display: flex; align-items: baseline; gap: 8px; padding-top: 10px; padding-bottom: 10px; padding-right: 8px;
                         border-radius: 8px; font-size: 16px; font-weight: normal; cursor: pointer; }
.chooser label.loc-row .loc-path { display: none; }
.chooser.searching label.loc-row .loc-name { display: none; }
.chooser.searching label.loc-row .loc-path { display: inline; font-size: 15px; color: var(--ink); }
.chooser label.loc-row.bound { color: var(--muted); cursor: default; }
.chooser details:not(.show-done) label.loc-row.done { display: none; }
.chooser.searching details label.loc-row.done { display: flex; }
.chooser.searching .show-done { display: none; }
.chooser .show-done { border: 0; background: none; color: var(--muted); padding: 8px; cursor: pointer; }
.chooser label.picked { background: #dbeafe; border-color: var(--brand); }
.chooser [hidden] { display: none !important; }
.chooser[hidden] { display: none !important; }
/* 掃到還沒綁的貼紙：先選貼在什麼上面（label-choose.js 換 data-mode） */
.scan-mode { display: grid; gap: 8px; margin-bottom: 12px; }
.scan-mode .btn { width: 100%; padding: 14px; font-size: 16px; text-align: left; }
.scan-mode .btn[aria-pressed=true] { background: #dbeafe; border-color: var(--brand); font-weight: 700; }
.chooser[data-mode=new] .mode-bind, .chooser[data-mode=bind] .mode-new { display: none !important; }
.chooser[data-mode=new] label.loc-row.bound { color: inherit; cursor: pointer; }
.chooser[data-mode=new] details label.loc-row.done { display: flex; }
.chooser[data-mode=new] .show-done { display: none; }
.chooser .new-fields { display: grid; gap: 6px; margin-bottom: 8px; }
.chooser .new-fields input[type=text] { font-size: 16px; }
.chooser label.loc-row { align-items: center; }
.chooser .thumb-slot { flex: 0 0 40px; width: 40px; height: 40px; }
.chooser .thumb-slot img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.chooser .thumb-slot img.look { display: none; opacity: .85; }
.chooser.searching .thumb-slot img.look { display: block; }
.danger-text { color: var(--danger); font-weight: 600; }
/* 小圖放大（zoom.js） */
img[data-zoom] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.zoom-pop { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
            background: rgba(15, 23, 42, .55); pointer-events: none; }
.zoom-pop[hidden] { display: none; }
.zoom-pop img { max-width: 92vw; max-height: 80vh; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
/* 手機按住的小預覽：不變暗、不擋操作（大小和位置在 zoom.js 算） */
.zoom-pop.small { inset: auto; display: block; background: none; }
.zoom-pop.small[hidden] { display: none; }
.zoom-pop.small img { display: block; width: 100%; height: 100%; object-fit: cover; border: 2px solid #fff; border-radius: 8px; }
/* 手機點一下才有的全螢幕大圖：點任何地方關閉 */
.zoom-pop.full { background: rgba(15, 23, 42, .9); pointer-events: auto; }
.zoom-pop.full img { max-width: 96vw; max-height: 86vh; }
.zoom-close { display: none; position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%;
              background: rgba(255, 255, 255, .92); color: #111827; font-size: 20px; line-height: 44px; padding: 0; }
.zoom-pop.full .zoom-close { display: block; }
/* iOS 要 cursor:pointer，點沒有連結的圖片才會有 click */
@media (hover: none) { img[data-zoom] { cursor: pointer; } }
.tree-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: 6px; flex: 0 0 36px; }
.tree-thumb-gap { display: inline-block; width: 36px; margin-right: 6px; flex: 0 0 36px; }
.chooser .bind-preview { margin-bottom: 8px; text-align: center; }
.chooser .bind-photo { position: relative; display: inline-block; max-width: 100%; }
.chooser .bind-photo img { display: block; max-width: 100%; max-height: 30vh; border-radius: 8px; }
.chooser .bind-box { position: absolute; border: 3px solid #f97316; border-radius: 4px; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.chooser .bind-bar { position: sticky; bottom: 0; padding: 10px 0 4px; background: var(--panel, #fff); }
.chooser .bind-bar button { width: 100%; font-size: 16px; padding: 12px; }
.chooser .bind-bar button.waiting { background: #e5e7eb; border-color: #d1d5db; color: var(--ink); }
.chooser .bind-nudge { margin: 0 0 8px; color: var(--warn); font-weight: 600; }
.chooser .bind-nudge[hidden] { display: none; }
ul.tree > li[hidden] { display: none; }
ul.tree > li .tree-toggle { margin-left: auto; min-width: 52px; }
.chooser label.loc-row.tree-hidden { display: none; }
.chooser.searching label.loc-row.tree-hidden:not([hidden]) { display: flex; }
.chooser .tree-toggle { margin-left: auto; min-width: 52px; min-height: 36px; flex: none; }
.chooser.searching .tree-toggle { display: none; }
.chooser .new-room { display: flex; gap: 8px; align-items: center; padding: 6px 8px; }
.chooser .new-room input { flex: 1; min-width: 0; }
.chooser .new-room .btn { white-space: nowrap; }
/* 位置屬性、歸到房間、在上一層照片上標出它 */
.kind-pick { margin: -4px 0 10px; }
.kind-pick summary { cursor: pointer; color: var(--muted); }
.kind-pick .kind-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.kind-pick .btn[aria-current=true] { background: #dbeafe; border-color: var(--brand); font-weight: 700; }
.place-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.rehome .rehome-rooms { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.rehome .inline-form { margin: 0; }
.frame-for { border-color: var(--brand); background: #eff6ff; }
.mode-more { margin: 8px 0; }
.mode-more .mode-choice { margin-bottom: 0; }
/* 位置頁：綁好之後「接著綁」 */
.next-bind-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 12px;
                 background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; }
.next-bind-bar > span { flex-basis: 100%; }
.label-name { font-weight: 700; }
.series-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; margin-bottom: 10px; }
label.series-option { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-weight: normal; cursor: pointer; }
label.series-option input { width: auto; margin-top: 4px; }
label.series-option > span { display: flex; flex-direction: column; }
label.series-option.used-up { opacity: .5; cursor: default; }
.series-next { color: var(--ink); }
.custom-names { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-bottom: 8px; }
.custom-name { display: inline-flex; align-items: center; gap: 2px; }
.custom-name button { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 4px; cursor: pointer; }
.custom-name button:hover { color: var(--danger); }
.unused-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; margin-bottom: 10px; }

/* 清單批次刪除（fragments/items :: bulk） */
ul.item-list .bulk-pick { flex: 0 0 auto; display: flex; align-items: center; padding: 6px 2px; cursor: pointer; }
ul.item-list .bulk-pick input { width: 20px; height: 20px; margin: 0; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.bulk-bar .btn { white-space: nowrap; }
.purge-summary { font-size: 15px; }
.purge-summary li { margin-bottom: 2px; }
.bulk-bar [data-bulk-toggle] { display: none; }
.bulk-optional:not(.bulk-on) .bulk-bar > :not([data-bulk-toggle]),
.bulk-optional:not(.bulk-on) .bulk-pick { display: none; }
.bulk-optional:not(.bulk-on) .bulk-bar [data-bulk-toggle] { display: inline-block; }

/* 一次拍好幾個盒子（batch.html、batch.js） */
.batch-howto { margin: 0 0 10px; padding-left: 22px; }
.batch-howto li { margin-bottom: 4px; }
.seg-head { display: flex; gap: 12px; align-items: flex-start; }
.seg-title { flex: 1; min-width: 0; }
.seg-qr { flex: 0 0 72px; width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #eef2f7;
    display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 26px; font-weight: 700; }
.seg-qr.sm { flex-basis: 40px; width: 40px; height: 40px; font-size: 16px; }
.seg-pick { margin: 6px 0; }
.seg-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.seg-photo { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.seg-photo img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.seg-photo .btn { padding: 2px 4px; font-size: 12px; }
.batch-progress { list-style: none; margin: 0 0 10px; padding: 0; }
.batch-progress li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg-run-name { font-weight: 600; flex: 1; min-width: 120px; }
.batch-group { margin-bottom: 18px; }
.seg-mode { margin-top: 6px; }
.seg-mode summary { cursor: pointer; color: var(--brand); }
.seg-mode .ai-hint { width: 100%; margin: 6px 0; }
.error-text { color: var(--danger); }
.ok-text { color: #166534; }

/* 拍房間（room.html）、照片當地圖、在照片上框一個位置（location.html、spot.js） */
.panel.detected.merged { opacity: .55; }
.spot-map { margin: 4px 0 12px; }
.annot-photo .box.spot { border-color: #2563eb; }
.annot-photo .box.spot span { background: #2563eb; color: #fff; white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.photo-card .spot-open { width: 100%; margin-bottom: 4px; }
/* 框的畫面佔滿整個螢幕（2026-11-07 她：很難框、在最下面邊緣容易誤觸）：照片盡量大、四周留空，手指碰不到手機邊緣的手勢 */
.spot-dialog { margin: 0; border: 0; padding: 0; width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
    background: #0f172a; color: #f8fafc; overflow: hidden; overscroll-behavior: none; }
.spot-dialog::backdrop { background: #0f172a; }
.spot-dialog form { height: 100%; }
.spot-step { height: 100%; display: flex; flex-direction: column; }
.spot-step[hidden] { display: none; }
.spot-top { padding: 10px 16px 4px; display: flex; flex-direction: column; gap: 2px; }
.spot-stage { position: relative; flex: 1; min-height: 0; padding: 12px 28px; display: flex; align-items: center; justify-content: center;
    touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
/* 框住照片本身（不留白邊）：框的比例才會剛好是照片的比例。大小由 spot.js 算 */
.spot-canvas { position: relative; line-height: 0; }
.spot-canvas img { display: block; width: 100%; height: 100%; border-radius: 4px; pointer-events: none; -webkit-user-drag: none; }
.spot-rect { position: absolute; border: 2px solid #38bdf8; background: rgba(56, 189, 248, .15); pointer-events: none; }
.spot-rect[hidden] { display: none; }
.spot-rect i { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid #0284c7; }
.spot-rect i:nth-child(1) { left: -9px; top: -9px; }
.spot-rect i:nth-child(2) { right: -9px; top: -9px; }
.spot-rect i:nth-child(3) { left: -9px; bottom: -9px; }
.spot-rect i:nth-child(4) { right: -9px; bottom: -9px; }
.spot-others { position: absolute; inset: 0; pointer-events: none; }
.spot-other { position: absolute; border: 1px dashed rgba(255, 255, 255, .85); }
.spot-other span { position: absolute; left: 0; top: 0; background: rgba(15, 23, 42, .75); color: #fff; font-size: 11px; line-height: 1.5; padding: 0 4px; white-space: nowrap; }
.spot-loupe { position: absolute; left: 8px; top: 8px; width: 130px; height: 130px; border-radius: 50%; border: 3px solid #fff;
    background-color: #000; background-repeat: no-repeat; box-shadow: 0 2px 10px rgba(0, 0, 0, .6); pointer-events: none; }
.spot-loupe[hidden] { display: none; }
.spot-loupe.right { left: auto; right: 8px; }
.spot-loupe.bottom { top: auto; bottom: 8px; }
.spot-loupe::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
    border: 2px solid #38bdf8; border-radius: 50%; }
.spot-bar { display: flex; gap: 10px; justify-content: space-between; padding: 12px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.spot-bar [data-spot-next] { margin-left: auto; min-width: 120px; }
.spot-bar [data-spot-redo][hidden] { display: none; }
/* 第二步：打名稱，一般的白底 */
.spot-name { background: var(--panel); color: var(--ink); padding: 16px 16px 0; overflow-y: auto; gap: 10px; }
.spot-name h2 { margin: 0; }
.spot-name .field { margin: 0; }
.spot-name > .btn.primary { width: 100%; min-height: 46px; }
.spot-name .spot-bar { margin-top: auto; padding-left: 0; padding-right: 0; }
.spot-preview { flex: none; width: auto; max-width: 60%; height: 28vh; align-self: center; background-repeat: no-repeat; border-radius: 6px; border: 1px solid var(--line); }
.spot-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.spot-chips .btn { min-height: 40px; }
.spot-chips .btn[hidden] { display: none; }
.spot-as-other .btn { width: 100%; }
.photo-marked { position: relative; line-height: 0; }
.photo-marked > a { display: block; aspect-ratio: 1; background: #f3f4f6; }
/* 位置的照片不裁切：框的比例才對得上（物品的照片照舊裁成正方形） */
.photo-marked.whole > a { aspect-ratio: auto; }
.photo-marked.whole img { height: auto; object-fit: contain; }
.spot-ai .flash-inline { color: var(--danger); }
.photo-marked .mark { position: absolute; border: 2px solid #2563eb; pointer-events: none; }
.photo-marked .mark span { position: absolute; left: -2px; top: -2px; background: #2563eb; color: #fff; font-size: 11px; line-height: 1.5; padding: 0 3px; white-space: nowrap; }
.spot-ai p { margin: 4px 0 8px; }
.spot-picks { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 6px 2px 0; }
.spot-review-bar { position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); }
.spot-review-bar .btn { width: 100%; min-height: 46px; }

/* 名稱可能不準、重讀字（NameReviewService、reread.js） */
.reread-link { margin-left: 6px; font-weight: 400; }
.reread-note { margin-top: 4px; }

/* 照片盤點、不用 AI（check.html、check.js） */
.check-viewer .viewer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.check-viewer .spacer { flex: 1; }
.viewer-stage { position: relative; line-height: 0; user-select: none; -webkit-user-select: none; }
.viewer-stage img { width: 100%; height: auto; border-radius: 8px; display: block; pointer-events: none; -webkit-user-drag: none; }
.viewer-stage.drawing { touch-action: none; cursor: crosshair; outline: 3px solid #2563eb; border-radius: 8px; }
.viewer-stage .box { position: absolute; border: 2px solid #16a34a; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; }
.viewer-stage .box span { position: absolute; left: -2px; top: -2px; transform: translateY(-100%); background: #16a34a; color: #fff;
    font-size: 12px; line-height: 1.4; padding: 1px 5px; border-radius: 3px 3px 0 0; white-space: nowrap; }
.viewer-stage .box.new { border-color: #f59e0b; }
.viewer-stage .box.new span { background: #f59e0b; color: #111; }
.draw-rect { position: absolute; border: 2px solid #2563eb; background: rgba(37, 99, 235, .15); pointer-events: none; }
.draw-hint { margin-top: 6px; color: #1d4ed8; font-weight: 600; line-height: 1.5; }
.viewer-actions { margin-top: 8px; }
.strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.strip-photo { margin: 0; flex: 0 0 84px; display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.strip-photo img { width: 84px; height: 64px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
.strip-photo.showing img { border-color: #2563eb; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.tile { border: 2px solid var(--line); border-radius: 8px; background: #fff; display: flex; flex-direction: column; }
.tile.seen { border-color: #16a34a; background: #f0fdf4; }
.tile.not { border-color: #f59e0b; background: #fffbeb; grid-column: 1 / -1; }
.tile-face { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 4px; padding: 6px; }
.tile.not .tile-face { flex-direction: row; align-items: center; }
.tile-thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; background: #eef2f7;
    border-radius: 6px; overflow: hidden; }
.tile.not .tile-thumb { width: 64px; flex: 0 0 64px; }
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile-thumb .thumb-empty { font-size: 22px; color: #94a3b8; font-weight: 700; }
.tile-thumb .thumb-tag { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; background: rgba(17,24,39,.6); color: #fff; }
.tile-name { font-size: 13px; font-weight: 600; line-height: 1.3; word-break: break-all; }
.tile-state { color: #166534; }
.tile.not .tile-state { color: #92400e; }
.tile-box { padding: 0 6px 6px; }
.tile-missing { padding: 0 8px 8px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tile-move { flex-basis: 100%; }
.new-row { display: flex; gap: 12px; align-items: flex-start; }
.new-row canvas.crop { width: 96px; height: 96px; flex: 0 0 96px; }
.new-fields { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rest-dialog { border: 0; border-radius: 10px; padding: 14px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.rest-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.rest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.rest-item { margin: 0; text-align: center; }
.rest-item img, .rest-item .thumb-empty { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: flex;
    align-items: center; justify-content: center; background: #eef2f7; }
.recheck-log { list-style: none; margin: 10px 0 0; padding: 0; }
.recheck-log li { padding: 8px 0; border-bottom: 1px solid var(--line); }
/* display 有設的元素，hidden 屬性要明寫才會藏起來 */
.tile-missing[hidden], .tile-move[hidden], .tile-box[hidden], .draw-hint[hidden] { display: none; }

/* busy.js：送出後固定在畫面最下面的狀態列（AI 辨識要幾十秒，看得到秒數在跳就知道還在跑、不用重按） */
.busy-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: var(--brand-dark); color: #fff; font-weight: 600; text-align: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .2);
}

/* 清單上的「📷 補照片」（fragments/attachments :: quick）：只是一顆小按鈕，不要照片區的虛線框 */
.photo-upload.quick-photo { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; }
.photo-upload.quick-photo .photo-status:empty { display: none; }
.tree .quick-photo { flex: 0 0 auto; margin-right: 6px; }
.tree .quick-photo .btn { width: 36px; height: 36px; padding: 0; line-height: 34px; text-align: center; }

/* 掃貼紙順便新增之後（location.html ?start=1）：只放拍裡面的東西 → 挑怎麼認 / 之後再拍 */
.start-card .photo-upload { margin-bottom: 10px; }
.start-card .photo-buttons label.btn { flex: 1; text-align: center; padding: 14px; font-size: 16px; }
.start-card .photo-grid.compact img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.start-ai, .mode-choice { display: grid; gap: 10px; margin: 12px 0; }
.start-ai .btn, .mode-choice .btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 12px 14px; text-align: left; }
.start-ai .btn b, .mode-choice .btn b { font-size: 17px; }
.start-ai .btn .small, .mode-choice .btn .small { font-weight: 400; opacity: .9; }
.mode-now { margin: 0 0 8px; }
/* 下一步、每張照片的用途（2026-11-08 她：引導字要寫清楚） */
.next-step { margin: 10px 0; padding: 8px 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; font-size: 14px; line-height: 1.5; }
.photo-purpose { margin-bottom: 6px; }
.photo-purpose p { margin: 4px 0 0; line-height: 1.45; }
.badge.brand { background: #dbeafe; color: #1d4ed8; }
.photo-delete-now { margin-bottom: 4px; }
.photo-delete-now .btn { width: 100%; }
/* 背景 AI 工作：每頁上面的狀態列（/js/jobs.js）、全部清單、確認頁離開的按鈕 */
.job-bar { position: sticky; top: 0; z-index: 50; max-height: 30vh; overflow-y: auto; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); font-size: 14px; line-height: 1.4; }
.job-bar-problem { flex: 1 1 200px; min-width: 0; color: inherit; text-decoration: none; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
/* 跳到 #photos、#row-1 這類位置時，不要被上面的狀態列蓋住 */
#photos, [id^="row-"], [id^="photo-"], #items, #children, #map, #labels { scroll-margin-top: 90px; }
.job-bar[hidden] { display: none; }
.job-bar.flash { animation: job-flash 1.4s ease-out; }
@keyframes job-flash { 0%, 40% { background: #bbf7d0; } 100% { background: #fff; } }
.job-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; }
.job-bar-row + .job-bar-row { border-top: 1px solid var(--line); }
.job-bar-row.ready { background: var(--ok-bg); }
.job-bar-row.failed { background: var(--danger-bg); color: #991b1b; }
.job-bar-row.working { color: var(--muted); font-size: 13px; }
.job-bar-row > span { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.job-bar-main { flex: 1 1 200px; min-width: 0; font-weight: 700; text-decoration: none; color: #166534; padding: 4px 0; }
.job-bar-more { font-size: 13px; white-space: nowrap; }
.job-bar-btn { padding: 4px 10px; border: 1px solid currentColor; border-radius: 6px; background: #fff; color: inherit; font: inherit; font-size: 13px; }
.job-list { list-style: none; margin: 12px 0 0; padding: 0; }
.job-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.job-thumb { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: #eef2f7; display: block; }
.job-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.job-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.job-leave { display: flex; flex-wrap: wrap; gap: 6px; }
.start-later { display: block; text-align: center; padding: 12px; color: var(--muted); }
.start-cover { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.start-cover img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; display: block; }

/* 用照片重讀名稱的確認頁（rename.html） */
.rename-list .info input[type=text] { width: 100%; font-size: 16px; margin: 2px 0; }
.rename-list .rename-old { text-decoration: line-through; }
.rename-list li.failed { opacity: .7; }

/* 閱讀頁（2026-11-06 她：看和改分開，閱讀時照片最重要）：item.html、location.html、搜尋結果 */
.read-page .crumbs { margin-bottom: 10px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin-bottom: 12px; }
.gallery-photo { flex: 0 0 88%; max-width: 560px; margin: 0; scroll-snap-align: start; position: relative; line-height: 0; }
.gallery-photo:only-child { flex-basis: 100%; }
.gallery-photo img { width: 100%; height: auto; display: block; border-radius: 10px; background: #f3f4f6; }
.no-photo { padding: 28px 16px; margin-bottom: 12px; text-align: center; color: var(--muted); background: #eef0f3; border-radius: 10px; }
.no-photo p { margin: 0; }
.read-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; margin-bottom: 4px; }
.read-title { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.read-title h1 { margin: 0; font-size: 22px; }
.read-head .btn { flex: 0 0 auto; }
.read-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.read-note { margin: 0 0 8px; white-space: pre-line; }
.read-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 18px; }
.read-actions form { display: inline-flex; margin: 0; }
.read-section { margin-bottom: 22px; }
.read-section > h2 { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-bottom: 10px; }
.trail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.trail-step { display: block; color: inherit; text-decoration: none; }
.trail-step .annot-photo { margin-bottom: 4px; }
.trail-name { font-size: 14px; font-weight: 600; }
.card-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card-grid li { position: relative; min-width: 0; }
.card { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.card-photo { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: #eef0f3; margin-bottom: 4px; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-photo .thumb-empty { font-size: 34px; color: #94a3b8; font-weight: 700; }
.card-photo .thumb-tag { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; text-align: center; background: rgba(17, 24, 39, .6); color: #fff; line-height: 1.6; }
.card-name { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.card-path { font-size: 12px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.card-grid .quick-photo { position: absolute; top: 6px; right: 6px; margin: 0; }
.card-grid .quick-photo .photo-status:empty { display: none; }
.card-grid .bulk-pick { position: absolute; top: 6px; left: 6px; z-index: 1; display: flex; padding: 3px; background: rgba(255, 255, 255, .9); border-radius: 5px; cursor: pointer; }
.card-grid .bulk-pick input { width: 20px; height: 20px; margin: 0; }
.bulk-optional .bulk-bar { margin-top: 12px; }

/* 管理頁：功能收合 */
details.ai-mode { display: block; }
details.ai-mode > summary { cursor: pointer; padding: 3px 0; }
details.ai-mode[open] > summary { margin-bottom: 6px; }
details.ai-mode > :not(summary) { margin-bottom: 6px; }
details.panel > summary a { margin-left: 8px; }
details.panel[open] > summary { margin-bottom: 10px; }
.photo-more { margin-top: 6px; }
.photo-more > summary { cursor: pointer; color: var(--muted); }
.photo-more[open] > summary { margin-bottom: 6px; }

@media (max-width: 600px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .trail-grid { grid-template-columns: 1fr; }
}
.manual-add { margin: 10px 0 12px; }

/* 新登記拍完的預覽：照片是 2000 多像素寬，沒限制會把整頁撐寬、手機畫面被縮小（2026-11-06 她回報） */
main img { max-width: 100%; }
.new-photo-preview { display: block; width: auto; height: auto; max-width: 100%; max-height: 40vh; margin-top: 8px; border-radius: 8px; }
.new-photo-preview[hidden] { display: none; }
