/* 配色 A：黑白中性色 + 相机黄（仅黑底激活态），与 App 共用 */
:root {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: #18181b;
  background: #f4f4f5;
  font-synthesis: none;
  --ink: #18181b;
  --ink-hover: #27272a;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --page: #f4f4f5;
  --surface: #fff;
  --stage: #0a0a0a;
  --accent: #ffd60a;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --header-h: 60px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button, input, select { min-height: 40px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-weight: 600; line-height: 1.4; }
p { line-height: 1.6; }
svg { flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 按钮：主按钮黑底白字；次要按钮白底细描边，全站统一 */
.button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; font-size: .9rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.primary { background: var(--ink); color: #fff; }
.primary:hover:not(:disabled) { background: var(--ink-hover); }
.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--page); border-color: var(--line-strong); }
.button.block { width: 100%; }
.button.small { font-size: .82rem; padding: 6px 12px; }
.button.icon-only { padding: 0; width: 40px; }
.hint { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.status { font-size: .85rem; margin: 0; overflow-wrap: anywhere; }
.status:empty { display: none; }
.error { color: var(--danger); }
input, select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; background: var(--surface); color: var(--ink); font-size: .9rem; }
input:hover, select:hover { border-color: var(--line-strong); }
input::placeholder { color: #a1a1aa; }
input[type="date"]:invalid { border-color: var(--danger); }
input[type="date"] { font-variant-numeric: tabular-nums; }

/* 品牌：黑色圆角方块 + 白色相机线框 */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 1rem; font-weight: 600; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* 顶栏 */
.site-header { position: sticky; top: 0; z-index: 10; height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 32px; }

/* 登录 */
main { min-width: 0; }
.login-panel { width: min(400px, calc(100% - 32px)); margin: max(12svh, 24px) auto 48px; background: var(--surface); border-radius: 12px; padding: 32px; box-shadow: 0 1px 2px #0000000a, 0 8px 24px #0000000a; }
.login-panel .brand { margin-bottom: 28px; }
.login-panel h1 { font-size: 1.35rem; margin-bottom: 6px; }
.intro { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: .85rem; font-weight: 600; }
.login-form input { min-height: 44px; }
.login-form .status { margin: 2px 0; }
.login-form .primary { min-height: 44px; margin-top: 6px; }
.privacy-note { margin: 20px 0 0; font-size: .76rem; color: var(--muted); }

/* 照片库：左侧项目导航 + 右侧照片区 */
.library { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 32px; max-width: 1680px; margin: 0 auto; padding: 24px 32px 40px; }
.sidebar { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; max-height: calc(100svh - var(--header-h) - 48px); overflow-y: auto; min-width: 0; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 12px 8px; }
.sidebar-heading h2 { font-size: .8rem; color: var(--muted); margin: 0; font-weight: 600; }
.sidebar-summary { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.project-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.project-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: .9rem; }
.project-item:hover { background: #ebebed; }
.project-item[aria-current="true"] { background: var(--line); font-weight: 600; }
.project-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-count { color: var(--muted); font-size: .8rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.library-main { min-width: 0; }
.project-select { display: none; }

/* 页面级提示条：左侧状态色竖条 */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 6px 6px 14px; margin-bottom: 16px; background: var(--surface); border-radius: 8px; border-left: 3px solid var(--warning); font-size: .85rem; }
.notice p { margin: 0; }

/* 筛选工具条 */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-field { position: relative; flex: 1 1 240px; min-width: 0; }
.search-field input { padding-left: 36px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.date-range { display: flex; align-items: center; gap: 6px; min-width: 0; }
.date-range input { width: 150px; }
.date-dash { color: var(--muted); }
.toolbar-end { display: flex; align-items: center; gap: 8px; }
.toolbar-end select { width: auto; }
.toolbar-hint { margin: 8px 0 0; font-size: .76rem; color: var(--muted); }
.toolbar-error { margin: 4px 0 0; font-size: .8rem; color: var(--danger); }
.toolbar-error:empty { display: none; }

/* 结果行 */
.results-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 14px; }
.results-heading h1 { font-size: 1.2rem; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.result-count { margin: 0; font-size: .85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 照片网格：图片优先瓦片 */
.photo-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px 16px; }
.photo-grid:empty { display: none; }
.photo-card { position: relative; min-width: 0; container-type: inline-size; }
.photo-open { width: 100%; padding: 0; display: block; text-align: left; background: none; border: 0; border-radius: 8px; min-height: 0; }
.thumbnail-frame { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--line); display: flex; align-items: center; justify-content: center; }
.thumbnail-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease, filter .2s ease; }
.photo-open:hover .thumbnail-frame img { transform: scale(1.03); filter: brightness(.9); }
.thumbnail-status { font-size: .76rem; color: var(--muted); text-align: center; padding: 8px; }
.thumbnail-retry { position: absolute; left: 50%; top: calc(50cqw + 14px); transform: translateX(-50%); }
.card-content { display: block; margin-top: 8px; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-line { display: block; margin-top: 1px; font-size: .75rem; color: var(--muted); line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-time { font-variant-numeric: tabular-nums; }

/* 空库、无结果、错误等状态 */
.grid-status { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 72px 20px; }
.grid-status-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--line); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.grid-status-icon > * { display: none; }
.grid-status[data-kind="loading"] .spinner,
.grid-status[data-kind="empty"] .icon-photo,
.grid-status[data-kind="filtered"] .icon-search,
.grid-status[data-kind="error"] .icon-error { display: block; }
.grid-status[data-kind="error"] .grid-status-icon { background: #dc26260f; color: var(--danger); }
.grid-status h2 { font-size: 1rem; margin-bottom: 4px; }
.grid-status p { color: var(--muted); font-size: .88rem; margin-bottom: 16px; max-width: 420px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 40px 0 8px; font-size: .88rem; font-variant-numeric: tabular-nums; }
.pagination .dot { color: var(--muted); }

/* 全屏照片查看器 */
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--stage); color: var(--ink); overflow: hidden; }
dialog.viewer::backdrop { background: var(--stage); }
.viewer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: 100%; }
.viewer-stage { display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--stage); color: #fff; min-width: 0; min-height: 0; }
.viewer-stage :focus-visible { outline-color: #fff; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; }
.stage-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 0; border-radius: 8px; background: #ffffff1f; color: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.stage-button:hover:not(:disabled) { background: #ffffff33; }
.stage-button.icon-only { width: 40px; padding: 0; }
.stage-toggle[aria-pressed="true"] { background: var(--accent); color: var(--ink); }
.stage-toggle[aria-pressed="true"]:hover:not(:disabled) { background: #ffe14d; }
.detail-image-frame { position: relative; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 0 24px 24px; }
.detail-image-frame img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.detail-image-frame.actual-size { display: block; }
.detail-image-frame.actual-size img { max-width: none; max-height: none; margin: auto; }
.image-state { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.image-status { margin: 0; color: #a1a1aa; font-size: .88rem; text-align: center; }
.image-status:empty { display: none; }
.viewer-panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 24px 16px; }
.panel-scroll h2 { font-size: 1.15rem; margin-bottom: 20px; overflow-wrap: anywhere; white-space: pre-wrap; }
.panel-scroll .notice { margin-bottom: 0; }
/* label 列取最长单个 label 的宽度，不换行 */
.metadata { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 16px; }
.metadata-row { display: contents; }
.metadata dt, .metadata dd { padding: 7px 0; align-self: baseline; }
.metadata dt { color: var(--muted); font-size: .8rem; line-height: 1.6; white-space: nowrap; }
.metadata dd { margin: 0; font-size: .86rem; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; font-variant-numeric: tabular-nums; }
.metadata .technical dd { font-size: .74rem; font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; color: #3f3f46; }
.panel-footer { padding: 16px 24px 20px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.download-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.download-actions .button { min-height: 44px; }
.panel-footer .hint { margin: 0; font-size: .76rem; }
.panel-footer .button.small { justify-self: start; }

/* 平板 */
@media (max-width: 1280px) {
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1600px) {
  .photo-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .library { grid-template-columns: 200px minmax(0, 1fr); gap: 24px; padding: 20px 24px 32px; }
  .site-header { padding: 0 24px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .viewer-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

/* 窄屏：项目导航退回为下拉选择，查看器上下排列 */
@media (max-width: 760px) {
  .library { display: block; padding: 16px 16px 32px; }
  .sidebar { display: none; }
  .project-select { display: block; flex: 1 1 100%; }
  .search-field { flex-basis: 100%; }
  .date-range { flex: 1 1 100%; }
  .date-range input { width: auto; flex: 1; }
  .toolbar-end { flex: 1 1 100%; }
  .toolbar-end select { flex: 1; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 12px; }
  .viewer-layout { display: flex; flex-direction: column; }
  .viewer-stage { height: 50svh; flex-shrink: 0; }
  .stage-bar { padding: 8px 12px; }
  .detail-image-frame { padding: 0 12px 12px; }
  .viewer-panel { flex: 1; }
  .panel-scroll { padding: 20px 16px 12px; }
  .panel-footer { padding: 12px 16px 16px; }
}
@media (max-width: 480px) {
  .site-header { padding: 0 16px; }
  .login-panel { padding: 28px 20px; margin-top: 8svh; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results-heading h1 { font-size: 1.1rem; }
  .pagination { gap: 8px; }
  .notice { flex-direction: column; align-items: stretch; padding: 10px 10px 10px 14px; }
}
