:root {
  --bg: #ffffff;
  --bg-soft: #f6f6f7;
  --surface: #ffffff;
  --text: #1a1a1c;
  --text-dim: #6b6b73;
  --line: rgba(0, 0, 0, 0.09);
  --accent: #185fa5;
  --radius: 12px;
  --header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --bg-soft: #1a1a1d;
    --surface: #1e1e21;
    --text: #f0f0f2;
    --text-dim: #9a9aa3;
    --line: rgba(255, 255, 255, 0.11);
    --accent: #85b7eb;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.meta { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.grow { flex: 1; }

.icon {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
}
.icon:hover { background: var(--bg-soft); }

/* ---------- 内容区 ---------- */

.view { padding: 18px; min-height: calc(100vh - var(--header-h)); }
.loading, .empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 80px 0;
}

.grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

@media (max-width: 640px) {
  .view { padding: 10px; }
  .grid { gap: 4px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* 相册卡片 */
.album {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  cursor: pointer;
  border: 0;
  padding: 0;
}
.album img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album .veil {
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  color: #fff;
  text-align: left;
}
.album .veil b { display: block; font-size: 14px; font-weight: 500; }
.album .veil span { font-size: 12px; opacity: 0.82; }

/* 照片格子 */
.photo {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-soft);
  cursor: zoom-in;
  border: 0;
  padding: 0;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.photo:hover img { transform: scale(1.04); }

.sentinel { height: 1px; }

/* ---------- 大图查看 ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 10, 12, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }

.lb-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.lb-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 20px 20px;
  color: #e9e9ec;
  font-size: 13px;
}
.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-index { color: #a5a5ad; font-variant-numeric: tabular-nums; }

.btn-download {
  flex: none;
  background: #fff;
  color: #111;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.btn-download:hover { background: #e6e6e9; }

.lb-close, .lb-nav {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  border-radius: 999px;
  line-height: 1;
}
.lb-close {
  top: 16px;
  right: 18px;
  width: 40px;
  height: 40px;
  font-size: 24px;
}
.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  font-size: 28px;
}
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.22); }

@media (max-width: 640px) {
  .lb-nav { display: none; }
}

/* ---------- 登录 ---------- */

.login {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 26px;
  text-align: center;
}
.login-card h2 { margin: 0 0 6px; font-size: 18px; font-weight: 500; }
.login-sub { margin: 0 0 22px; font-size: 13px; color: var(--text-dim); }

.login-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  margin-bottom: 14px;
}
.login-card input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

.login-error { margin: 12px 0 0; font-size: 13px; color: #e24b4a; }

/* ---------- 顶栏的「分享管理」按钮 ---------- */

.text-btn {
  border: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.text-btn:hover { background: var(--line); }

/* ---------- 相册卡片上的「分享」小按钮 ---------- */

.album-wrap { position: relative; }
.album-share {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  border: 0;
  background: rgba(20, 20, 22, 0.62);
  color: #fff;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.16s ease;
  backdrop-filter: blur(6px);
}
.album-wrap:hover .album-share { opacity: 1; }
.album-share:hover { background: rgba(20, 20, 22, 0.86); }
@media (hover: none) {
  .album-share { opacity: 1; }
}

/* ---------- 分享管理面板 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 500; }

.modal-body { padding: 18px 20px 24px; overflow-y: auto; }

.sec { margin-bottom: 26px; }
.sec:last-child { margin-bottom: 0; }
.sec h3 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
}
.picker label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  cursor: pointer;
}
.picker label.on { border-color: var(--accent); color: var(--accent); }
.picker input { accent-color: var(--accent); }
.picker .hint { font-size: 12px; color: var(--text-dim); }

.share-msg { margin: 12px 0 0; font-size: 13px; }
.share-msg.ok { color: #1d9e75; }
.share-msg.err { color: #e24b4a; }

.share-items { display: flex; flex-direction: column; gap: 10px; }
.share-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
  background: var(--bg-soft);
}
.share-item .row1 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.share-item .ttl { font-size: 14px; font-weight: 500; flex: 1; }
.share-item .cnt { font-size: 12px; color: var(--text-dim); }
.share-item .url {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.5;
}
.share-item .acts { display: flex; gap: 8px; margin-top: 10px; }
.mini {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.mini:hover { border-color: var(--color-border-secondary); }
.mini.danger { color: #e24b4a; }
.share-empty { font-size: 13px; color: var(--text-dim); padding: 6px 0; }
