/* 家族相冊 全站樣式 — Tiffany 綠設計系統 */
:root {
    --primary: #81D8D0;
    --primary-hover: #6AC1B9;
    --primary-container: #E6F7F5;
    --on-primary-container: #004D47;
    --link: #0B7A72;
    --bg: #f7f6f4;
    --card-bg: #ffffff;
    --text: #212529;
    --text-muted: #495057;
    --text-faint: #868E96;
    --border: #E9ECEF;
    --outline: #CED4DA;
    --danger: #d64545;
    --success: #2f9e6e;
    --radius: 12px;
    --radius-card: 24px;
    --shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 12px 32px 0 rgba(0, 0, 0, 0.08);
    --font-body: "Be Vietnam Pro", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --font-heading: "Be Vietnam Pro", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 屬性永遠優先於任何 display 設定 */
[hidden] { display: none !important; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
}

h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; }
a { color: var(--link); text-decoration: none; }

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    user-select: none;
}
.btn .material-symbols-outlined { font-size: 1.25rem; }

/* ---- 桌面頂欄 ---- */
.topnav {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem; height: 72px;
    padding: 0 2.5rem; background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.brand {
    display: flex; align-items: center; gap: 0.5rem;
    font-family: var(--font-heading); font-size: 1.35rem; font-weight: 700;
    color: var(--text); white-space: nowrap;
}
.brand-icon { color: var(--primary); font-size: 1.9rem; font-variation-settings: 'FILL' 1; }
.nav-links {
    display: flex; align-items: center; gap: 1.5rem;
    white-space: nowrap; font-size: 0.92rem; font-weight: 500;
}
.nav-links a { color: var(--text-muted); padding: 0.35rem 0; border-bottom: 2px solid transparent; }
.nav-links a:hover { color: var(--link); }
.nav-links a.nav-active { color: var(--link); border-bottom-color: var(--primary); font-weight: 700; }
.nav-right { display: flex; align-items: center; gap: 1.25rem; }
.nav-logout { color: var(--text-muted); }
.nav-account {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.88rem; color: var(--text); white-space: nowrap;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 9999px; padding: 0.3rem 0.75rem 0.3rem 0.5rem;
}
.nav-account .material-symbols-outlined { font-size: 1.35rem; color: var(--text-muted); }
.role-badge {
    font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.5rem;
    border-radius: 9999px; background: var(--surface-variant, #E9ECEF);
    background: var(--border); color: var(--text-muted);
}
.role-badge.role-admin { background: var(--primary-container); color: var(--on-primary-container); }

/* ---- 手機底部導覽列 ---- */
.bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--card-bg); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px 0 rgba(0, 0, 0, 0.04);
    justify-content: space-around; align-items: center;
    padding: 0.4rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
    padding: 0.35rem 1rem; border-radius: 12px; border: none; background: none;
    font-family: var(--font-body); font-size: 0.72rem; font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}
.bottom-nav-item:active { transform: scale(0.92); }
.bottom-nav-item .material-symbols-outlined { font-size: 1.5rem; }
.bottom-nav-active {
    background: var(--primary-container); color: var(--on-primary-container); font-weight: 700;
}
.bottom-nav-active .material-symbols-outlined { color: var(--link); font-variation-settings: 'FILL' 1; }

@media (max-width: 767px) {
    /* 手機:精簡頂欄(品牌 + 帳號),功能連結移到底部導覽列 */
    .topnav { height: 56px; padding: 0 1rem; }
    .nav-links { display: none; }
    .brand { font-size: 1.05rem; }
    .brand-icon { font-size: 1.5rem; }
    .nav-account { font-size: 0.82rem; }
    .bottom-nav { display: flex; }
    body.has-bottom-nav { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ---- 版面 ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 2rem 2.5rem 3rem; }
.container-narrow { max-width: 640px; }
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 2rem; }
.page-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.back-link {
    display: inline-flex; align-items: center; gap: 0.25rem;
    font-size: 0.9rem; margin-bottom: 0.5rem; font-weight: 500;
}
.back-link .material-symbols-outlined { font-size: 1.15rem; }
.album-meta { color: var(--text-muted); font-size: 0.95rem; }
.album-description { margin-top: 0.5rem; color: var(--text); max-width: 60ch; }
@media (max-width: 640px) {
    .container { padding: 1.25rem 1rem 2rem; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header h1 { font-size: 1.5rem; }
    .page-actions .btn { flex: 1 1 auto; text-align: center; }
}

/* ---- 按鈕(膠囊型) ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.6rem 1.1rem; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
    font-family: var(--font-body); font-size: 0.92rem; font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer; transition: all 0.2s ease;
}
.btn:hover { background: #f6f5f3; border-color: var(--outline); }
.btn-primary {
    background: var(--primary); border-color: var(--primary);
    color: #ffffff; font-weight: 600; border-radius: 9999px;
    padding: 0.6rem 1.4rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    text-shadow: 0 1px 2px rgba(0, 60, 55, 0.25);
}
.btn-primary:hover {
    background: var(--primary-hover); border-color: var(--primary-hover); color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(129, 216, 208, 0.45);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(129, 216, 208, 0.35); }
.btn-danger { color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.85rem; }
.btn-block { display: flex; width: 100%; }
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
}

/* ---- 卡片與表單 ---- */
.card {
    background: var(--card-bg); border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-card); padding: 1.75rem; margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 1.2rem; margin-bottom: 1rem; }
label { display: block; font-size: 0.88rem; font-weight: 600; margin: 0.85rem 0 0.3rem; }
input[type="text"], input[type="password"], input[type="date"], textarea, select {
    width: 100%; padding: 0.6rem 0.9rem; border: 1px solid var(--outline);
    border-radius: var(--radius); font-size: 16px; font-family: inherit; background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(129, 216, 208, 0.35);
}
.form-stacked .form-actions { margin-top: 1.5rem; display: flex; gap: 0.6rem; }
.form-inline-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem; align-items: end;
}
.field-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.access-fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem 1rem; margin-top: 1rem; }
.access-fieldset legend { font-size: 0.9rem; font-weight: 600; padding: 0 0.3rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.4rem; }
.checkbox-item { display: flex; align-items: center; gap: 0.4rem; font-weight: 400; margin: 0; font-size: 0.95rem; }

/* ---- 提示 ---- */
.alert { padding: 0.8rem 1.1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.95rem; }
.alert-error { background: #fdecec; color: var(--danger); border: 1px solid #f5c6c6; }
.alert-success { background: var(--primary-container); color: var(--on-primary-container); border: 1px solid #bfe8e3; }
.text-muted { color: var(--text-muted); }

/* ---- 登入頁 ---- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 1rem; position: relative; overflow: hidden;
    background: linear-gradient(135deg, #EDF9F8 0%, #DDF1EE 45%, #F3EFE8 100%);
    background-size: 200% 200%;
    animation: gradient-drift 16s ease-in-out infinite;
}
/* 漂浮光斑 */
.login-page::before, .login-page::after {
    content: ''; position: absolute; border-radius: 50%;
    filter: blur(70px); opacity: 0.55; pointer-events: none;
}
.login-page::before {
    width: 380px; height: 380px; background: #81D8D0;
    top: -110px; left: -90px;
    animation: blob-float 11s ease-in-out infinite;
}
.login-page::after {
    width: 320px; height: 320px; background: #ffd9b8;
    bottom: -100px; right: -70px;
    animation: blob-float 13s ease-in-out infinite reverse;
}
.login-card {
    position: relative; z-index: 1;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-card); padding: 2.5rem 2rem;
    width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0, 77, 71, 0.14);
    text-align: center;
    animation: card-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.login-logo {
    width: 76px; height: 76px; margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 24px;
    background: linear-gradient(150deg, #A7E6E0 0%, var(--primary) 60%, #5FBDB4 100%);
    box-shadow: 0 8px 24px rgba(129, 216, 208, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    animation: logo-float 4.5s ease-in-out infinite;
}
.login-logo .material-symbols-outlined {
    font-size: 2.5rem; color: #fff;
    text-shadow: 0 1px 3px rgba(0, 60, 55, 0.25);
    font-variation-settings: 'FILL' 1, 'wght' 300;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; animation: fade-up 0.6s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; animation: fade-up 0.6s 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.login-card form { text-align: left; animation: fade-up 0.6s 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.login-card .btn { margin-top: 1.25rem; }
.remember-me { margin-top: 1rem; font-size: 0.9rem; color: var(--text-muted); }
.remember-me input { accent-color: var(--primary); width: auto; }
.login-hint { margin-top: 1.25rem; font-size: 0.85rem; color: var(--text-faint); animation: fade-up 0.6s 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes gradient-drift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
@keyframes blob-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, 30px) scale(1.12); }
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(28px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes logo-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-7px); }
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- 相簿列表 ---- */
.album-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 2rem;
}
@media (max-width: 640px) { .album-grid { grid-template-columns: 1fr; gap: 1.25rem; } }
.album-card {
    background: var(--card-bg); border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-card);
    overflow: hidden; color: var(--text); transition: all 0.3s ease; box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    animation: fade-up 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.album-card:nth-child(2) { animation-delay: 0.07s; }
.album-card:nth-child(3) { animation-delay: 0.14s; }
.album-card:nth-child(4) { animation-delay: 0.21s; }
.album-card:nth-child(5) { animation-delay: 0.28s; }
.album-card:nth-child(n+6) { animation-delay: 0.34s; }
@media (hover: hover) {
    .album-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
    .album-card:hover .album-cover img { transform: scale(1.05); }
}
.album-cover { aspect-ratio: 4 / 3; background: var(--border); overflow: hidden; }
.album-cover img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform 0.5s ease;
}
.album-cover-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--outline); }
.album-cover-empty .material-symbols-outlined { font-size: 3.5rem; }
.album-info { padding: 1.1rem 1.25rem 1.25rem; display: flex; flex-direction: column; flex: 1; }
.album-info h2 { font-size: 1.2rem; margin-bottom: 0.2rem; }
.album-info .album-meta { flex: 1; margin-bottom: 0.75rem; }
.album-creator { font-size: 0.78rem; color: var(--text-faint); }

/* ---- 相簿地圖檢視 ---- */
#album-map {
    height: 72vh; border-radius: var(--radius-card); overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05); box-shadow: var(--shadow); z-index: 0;
}
.photo-marker img {
    width: 56px; height: 56px; object-fit: cover;
    border-radius: 10px; border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.photo-marker:hover img { border-color: var(--primary); }

/* ---- 排序與縮圖大小工具列 ---- */
.grid-toolbar {
    display: flex; justify-content: flex-end; align-items: center;
    gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.grid-toolbar-label { margin: 0; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.grid-toolbar select { width: auto; padding: 0.45rem 2rem 0.45rem 0.75rem; font-size: 0.88rem; }
.size-switch {
    display: inline-flex; border: 1px solid var(--border); border-radius: 9999px;
    overflow: hidden; background: var(--card-bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.size-switch button {
    border: none; background: none; padding: 0.45rem 0.75rem; cursor: pointer;
    color: var(--text-muted); display: flex; align-items: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.size-switch button:hover { color: var(--text); }
.size-switch button.active { background: var(--primary-container); color: var(--on-primary-container); }
.size-switch .material-symbols-outlined { font-size: 1.2rem; }

/* ---- 照片牆 ---- */
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.photo-grid.size-sm { grid-template-columns: repeat(6, 1fr); gap: 0.75rem; }
.photo-grid.size-lg { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
@media (max-width: 900px) {
    .photo-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
    .photo-grid.size-sm { grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
    .photo-grid.size-lg { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
}
@media (max-width: 560px) {
    .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
    .photo-grid.size-sm { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
    .photo-grid.size-lg { grid-template-columns: repeat(1, 1fr); gap: 1.25rem; }
    .grid-toolbar { justify-content: space-between; }
}
.photo-item {
    position: relative; border: none; padding: 0; cursor: pointer;
    aspect-ratio: 1 / 1; border-radius: 16px; overflow: hidden; background: var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease;
}
.photo-item:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s ease; }
@media (hover: hover) {
    .photo-item:hover img { transform: scale(1.04); }
}
.video-badge {
    display: none; position: absolute; inset: 0; margin: auto;
    width: 48px; height: 48px; line-height: 48px; text-align: center;
    border-radius: 50%; background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    color: #fff; font-size: 1.2rem; padding-left: 4px; pointer-events: none;
}
.photo-item--video .video-badge { display: block; }
.photo-check {
    position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
    border-radius: 50%; background: rgba(255, 255, 255, 0.85); color: transparent;
    display: none; align-items: center; justify-content: center; font-weight: 700;
    border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.select-mode .photo-check { display: flex; }
.photo-item.selected .photo-check { background: var(--primary); color: var(--on-primary-container); }
.photo-item.selected img { opacity: 0.7; }
.select-bar {
    position: sticky; top: 8px; z-index: 40; display: flex; align-items: center; gap: 0.6rem;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 9999px;
    padding: 0.5rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); font-size: 0.95rem;
}
@media (min-width: 768px) { .select-bar { top: 84px; } }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .btn { margin-top: 0.75rem; }

/* ---- Lightbox ---- */
.lightbox {
    position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.92);
    display: flex; align-items: center; justify-content: center;
}
.lightbox img#lb-image { max-width: 92vw; max-height: 84vh; object-fit: contain; }
.lightbox video#lb-video { max-width: 92vw; max-height: 84vh; background: #000; }
.save-hint {
    position: absolute; top: 14px; left: 50%; transform: translateX(-50%) translateY(-8px);
    z-index: 103; background: rgba(0, 0, 0, 0.7); color: #fff;
    padding: 0.5rem 1.1rem; border-radius: 9999px; font-size: 0.85rem;
    white-space: nowrap; pointer-events: none; opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.save-hint-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.lightbox-close {
    position: absolute; top: 12px; right: 16px; font-size: 1.4rem; background: none;
    border: none; color: #fff; cursor: pointer; z-index: 101;
}
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%); font-size: 2.5rem;
    background: rgba(255, 255, 255, 0.1); border: none; color: #fff; cursor: pointer;
    width: 52px; height: 80px; border-radius: var(--radius); z-index: 101;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }
.lightbox-bar {
    position: absolute; bottom: 0; left: 0; right: 0; display: flex;
    justify-content: space-between; align-items: center; gap: 1rem;
    padding: 0.75rem 1.25rem; background: rgba(0, 0, 0, 0.6); color: #eee; font-size: 0.9rem;
}
.lightbox-actions { display: flex; gap: 0.5rem; }
.lightbox-bar .btn { background: rgba(255, 255, 255, 0.12); border-color: transparent; color: #fff; }
.lightbox-bar .btn:hover { background: rgba(255, 255, 255, 0.28); color: #fff; }
.lightbox-map {
    position: absolute; bottom: 64px; right: 16px; z-index: 102;
    width: min(360px, calc(100vw - 32px));
    background: var(--card-bg); border-radius: var(--radius); overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
#lb-map-canvas { width: 100%; height: 240px; }
.lightbox-map-link {
    display: block; padding: 0.5rem 0.75rem; font-size: 0.85rem;
    text-align: center; border-top: 1px solid var(--border);
}
.lightbox-info {
    position: absolute; top: 16px; right: 16px; z-index: 102;
    width: min(300px, calc(100vw - 32px)); max-height: calc(100vh - 120px);
    overflow-y: auto; background: var(--card-bg); border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); padding: 0.9rem 1.1rem 1.1rem;
}
.lightbox-info-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.lightbox-info-header h3 { font-size: 1rem; }
.lightbox-info dt { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.6rem; }
.lightbox-info dd { font-size: 0.92rem; word-break: break-all; }
.lightbox-info-maplink { margin-top: 0.6rem; }

@media (max-width: 640px) {
    .lightbox img#lb-image, .lightbox video#lb-video { max-width: 100vw; max-height: 76vh; }
    .lightbox-nav {
        width: 40px; height: 64px; font-size: 1.8rem;
        background: rgba(255, 255, 255, 0.06);
    }
    .lightbox-bar {
        flex-direction: column; align-items: stretch; gap: 0.5rem;
        padding: 0.6rem 0.9rem calc(0.6rem + env(safe-area-inset-bottom));
    }
    #lb-info { font-size: 0.8rem; text-align: center; }
    .lightbox-actions { justify-content: center; flex-wrap: wrap; }
    .lightbox-actions .btn { white-space: nowrap; flex: 1 1 auto; }
    .lightbox-map { bottom: auto; top: 12px; right: 12px; left: 12px; width: auto; }
    #lb-map-canvas { height: 200px; }
    .lightbox-info { top: 12px; right: 12px; left: 12px; width: auto; max-height: 60vh; }
}

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
    background: var(--card-bg); border-radius: var(--radius-card); width: 100%;
    max-width: 440px; max-height: 90vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.15rem; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 1.5rem; }
.modal-body hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0 0.5rem; }
.modal-body .btn-block { margin-top: 1.25rem; }
.share-url-row { display: flex; gap: 0.5rem; }
.share-url-row input { flex: 1; font-size: 0.85rem; }
.share-status-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; font-size: 0.9rem; flex-wrap: wrap; }
.share-qrcode { display: flex; justify-content: center; margin-top: 1rem; }
@media (max-width: 640px) {
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal {
        max-width: 100%; max-height: 92vh;
        border-radius: var(--radius-card) var(--radius-card) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ---- 上傳進度 ---- */
.upload-progress {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.9rem 1.5rem; box-shadow: var(--shadow-hover); z-index: 80;
    min-width: 280px; text-align: center;
}
.upload-progress-track { height: 8px; background: var(--border); border-radius: 4px; margin-top: 0.5rem; overflow: hidden; }
.upload-progress-hint { margin-top: 0.45rem; font-size: 0.75rem; color: var(--text-faint); }
.upload-progress-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.2s ease; }
@media (max-width: 640px) {
    .upload-progress { width: calc(100vw - 32px); min-width: 0; bottom: calc(90px + env(safe-area-inset-bottom)); }
    .select-bar { flex-wrap: wrap; border-radius: var(--radius); }
}

/* ---- 拖放 ---- */
body.dragging::after {
    content: '放開以上傳照片'; position: fixed; inset: 0; z-index: 200;
    background: rgba(129, 216, 208, 0.92); color: var(--on-primary-container); font-size: 1.6rem;
    display: flex; align-items: center; justify-content: center;
}

/* ---- 表格 ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.row-disabled td { opacity: 0.55; }
.table-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.inline-form { display: inline; }
@media (max-width: 640px) {
    /* 手機:表格轉為卡片式排版 */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        background: var(--card-bg); border: 1px solid var(--border);
        border-radius: 16px; padding: 0.85rem 1.1rem; margin-bottom: 0.85rem;
        box-shadow: var(--shadow);
    }
    .data-table td {
        border: none; padding: 0.3rem 0;
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        font-size: 0.95rem;
    }
    .data-table td::before {
        content: attr(data-label);
        color: var(--text-muted); font-size: 0.82rem; font-weight: 500; flex-shrink: 0;
    }
    .data-table td.table-actions {
        justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap;
        padding-top: 0.7rem; margin-top: 0.4rem; border-top: 1px solid var(--border);
    }
    .data-table td.table-actions::before { content: none; }
    .data-table td.table-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
