/* ========== 基础 ========== */
:root {
  --bg: #f7f3ec;
  --bg-soft: #fdfbf7;
  --ink: #221f1c;
  --ink-2: #554e46;
  --muted: #8d857b;
  --line: #e7dfd3;
  --line-soft: #f0eae1;
  --accent: #9a6b4f;
  --accent-soft: #c9a888;
  --danger: #b4442f;
  --ok: #4a7c59;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 34px rgba(70, 48, 30, .09);
  --shadow-sm: 0 2px 10px rgba(70, 48, 30, .07);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, system-ui, sans-serif;
  --header-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body.lb-open { overflow: hidden; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: .02em;
  margin: 0;
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
input, textarea, select { font-family: inherit; font-size: 16px; }

::selection { background: #e9d9c6; }

/* ========== 启动 ========== */
.boot {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .12em;
}
.boot-ring {
  width: 30px; height: 30px;
  border: 1.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 登录 ========== */
.login {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: 50% 32%;
  filter: blur(18px) saturate(.85) brightness(.92);
  transform: scale(1.06);
  opacity: .5;
}
.login-bg::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(247,243,236,.72), rgba(247,243,236,.94) 55%, var(--bg));
}
.login-card {
  position: relative;
  width: min(410px, 100%);
  background: rgba(255,253,249,.9);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 38px 32px 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: rise .5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.login-heart {
  width: 40px; height: 40px;
  margin: 0 auto 16px;
  display: block;
}
.login h1 {
  font-size: 25px;
  text-align: center;
  letter-spacing: .06em;
}
.login .sub {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin: 9px 0 26px;
  letter-spacing: .04em;
}
.login .field { margin-bottom: 14px; }
.login .btn-primary { width: 100%; margin-top: 10px; padding: 13px; }
.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .05em;
}

/* ========== 表单 ========== */
.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .06em;
}
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(154,107,79,.12);
}
textarea { resize: vertical; min-height: 76px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14.5px;
  letter-spacing: .02em;
  transition: background .16s, border-color .16s, transform .1s, color .16s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent-soft); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
  letter-spacing: .08em;
}
.btn-primary:hover { background: #8a5d43; border-color: #8a5d43; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(154,107,79,.08); }
.btn-danger { color: var(--danger); border-color: #ecd6d1; }
.btn-danger:hover { background: #fbf0ee; border-color: #e0bdb5; color: var(--danger); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ========== 顶栏 ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: rgba(247,243,236,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner {
  height: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 max(18px, env(safe-area-inset-left));
}
.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}
.brand b {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: .1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand small {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 6px; }

/* ========== 页面容器 ========== */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px max(18px, env(safe-area-inset-left)) 80px;
  animation: fade .28s ease both;
}
@keyframes fade { from { opacity: 0; } }
.page-head { margin-bottom: 22px; }
.page-head h2 {
  font-size: 26px;
  letter-spacing: .06em;
}
.page-head p { color: var(--muted); font-size: 13.5px; margin: 7px 0 0; letter-spacing: .03em; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  letter-spacing: .05em;
}
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--accent); }

/* ========== 相册列表 ========== */
.albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 18px;
}
.album-card {
  display: block;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #eee7dc;
  box-shadow: var(--shadow-sm);
  transition: transform .25s cubic-bezier(.2,.7,.3,1), box-shadow .25s;
}
.album-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.album-cover {
  aspect-ratio: 4 / 5;
  width: 100%;
  object-fit: cover;
  object-position: 50% 38%;
  background: #e8e1d6;
  transition: transform .6s cubic-bezier(.2,.7,.3,1);
}
.album-card:hover .album-cover { transform: scale(1.035); }
.album-meta {
  position: absolute;
  inset: auto 0 0 0;
  padding: 40px 15px 14px;
  background: linear-gradient(180deg, rgba(20,15,10,0), rgba(20,15,10,.62));
  color: #fff;
}
.album-meta b {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: .1em;
}
.album-meta span {
  font-size: 11.5px;
  opacity: .78;
  letter-spacing: .1em;
}
.album-empty .album-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .1em;
  background: repeating-linear-gradient(45deg, #efe8dd, #efe8dd 10px, #eae2d6 10px, #eae2d6 20px);
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .06em;
}
.empty h3 { font-size: 19px; margin-bottom: 10px; color: var(--ink-2); }

/* ========== 照片网格 ========== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.tile {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: #eae3d8;
  cursor: zoom-in;
  margin: 0;
}
.tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 40%;
  transition: transform .5s cubic-bezier(.2,.7,.3,1), opacity .4s;
  opacity: 0;
}
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.04); }
.tile .badge {
  position: absolute;
  left: 7px; top: 7px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10.5px;
  background: rgba(255,255,255,.9);
  color: var(--ink-2);
  letter-spacing: .06em;
}
.tile .badge.err { background: #fbe9e6; color: var(--danger); }
.tile .check {
  position: absolute;
  right: 7px; top: 7px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.95);
  background: rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
}
.tile.selected .check { background: var(--accent); border-color: #fff; }
.tile.selected::after {
  content: "";
  position: absolute; inset: 0;
  border: 3px solid var(--accent);
  border-radius: 6px;
  pointer-events: none;
}

/* ========== 灯箱 ========== */
.lb[hidden] { display: none; }
.lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(14, 12, 10, .96);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lbfade .22s ease both;
}
@keyframes lbfade { from { opacity: 0; } }
.lb-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 0 48px;
}
.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .3s;
  will-change: opacity;
}
.lb-img.ready { opacity: 1; }
.lb-loading {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: none;
}
.lb.loading .lb-loading { display: block; }
.lb-loading span {
  display: block;
  width: 26px; height: 26px;
  border: 1.5px solid rgba(255,255,255,.2);
  border-top-color: rgba(255,255,255,.85);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.lb-bar {
  position: absolute;
  left: 0; right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #f2ece4;
  font-size: 13px;
}
.lb-top {
  top: 0;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(0,0,0,.55), transparent);
}
.lb-bottom {
  bottom: 0;
  justify-content: center;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,.55), transparent);
  flex-wrap: wrap;
  letter-spacing: .08em;
}
.lb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-btn {
  min-width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px;
  background: rgba(255,255,255,.1);
  color: #f4efe7;
  font-size: 14px;
  padding: 0 12px;
  transition: background .16s;
}
.lb-btn:hover { background: rgba(255,255,255,.2); }
.lb-orig.on { background: var(--accent); }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 52px; height: 84px;
  border: none;
  background: rgba(255,255,255,.06);
  color: #f4efe7;
  font-size: 30px;
  line-height: 1;
  border-radius: 12px;
  transition: background .16s;
}
.lb-nav:hover { background: rgba(255,255,255,.16); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-count { opacity: .7; font-variant-numeric: tabular-nums; }
.lb-caption { opacity: .85; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ========== 管理后台 ========== */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none;
  background: transparent;
  padding: 10px 15px;
  color: var(--muted);
  font-size: 14.5px;
  letter-spacing: .07em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .16s, border-color .16s;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.panel > h3 {
  font-size: 17px;
  margin-bottom: 4px;
  letter-spacing: .08em;
}
.panel > .hint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 16px;
  letter-spacing: .03em;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.row .field { flex: 1 1 190px; margin: 0; }

.list { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border-radius: 10px; overflow: hidden; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item b { font-weight: 500; font-size: 15px; }
.list-item .meta { color: var(--muted); font-size: 12.5px; letter-spacing: .03em; }
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  letter-spacing: .06em;
  background: #eee6da;
  color: var(--ink-2);
}
.pill.warn { background: #fbeee2; color: #a4673a; }
.pill.off { background: #efe9e4; color: var(--muted); }
.pill.ok { background: #e8f0e9; color: var(--ok); }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  transition: border-color .16s, background .16s;
  cursor: pointer;
  letter-spacing: .05em;
}
.drop:hover, .drop.over { border-color: var(--accent-soft); background: rgba(154,107,79,.05); color: var(--accent); }
.progress {
  height: 4px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 12px;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }
.selbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  background: #f3ece2;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13.5px;
  color: var(--ink-2);
  flex-wrap: wrap;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  letter-spacing: .05em;
}
.chip:hover { border-color: var(--accent-soft); color: var(--accent); }

.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; }
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.linkbox {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.linkbox input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #f8f4ee;
}

/* ========== 提示 ========== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 200;
  padding: 11px 20px;
  border-radius: 30px;
  background: rgba(34,31,28,.93);
  color: #f7f3ec;
  font-size: 13.5px;
  letter-spacing: .05em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(150,50,35,.95); }

/* ========== 移动端 ========== */
@media (max-width: 720px) {
  :root { --header-h: 56px; }
  .page { padding: 18px 12px 70px; }
  .page-head h2 { font-size: 22px; }
  .albums { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .album-meta { padding: 26px 10px 9px; }
  .album-meta b { font-size: 14.5px; letter-spacing: .06em; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .tile { border-radius: 4px; }
  .lb-nav { display: none; }
  .lb-stage { padding: 52px 0 44px; }
  .lb-btn { min-width: 38px; height: 38px; padding: 0 9px; font-size: 13px; }
  .panel { padding: 15px; }
  .list-item { padding: 11px 12px; gap: 9px; }
  .login-card { padding: 30px 22px 24px; }
  .toolbar { gap: 6px; }
  .header-inner { padding: 0 12px; gap: 8px; }
}

@media (min-width: 721px) and (max-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1600px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
