:root {
  --bg: #0b0d10;
  --bg-deep: #08090b;
  --panel: #111419;
  --panel-2: #161a20;
  --card: #181c23;
  --card-hover: #1e232c;
  --text: #f1eee7;
  --muted: #929baa;
  --muted-2: #6f7887;
  --line: #262c36;
  --accent: #e3b56c;
  --accent-soft: rgba(227, 181, 108, 0.14);
  --danger: #e87979;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(227, 181, 108, 0.07), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(92, 126, 180, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: linear-gradient(160deg, rgba(24, 28, 35, 0.96), rgba(14, 17, 21, 0.98));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 38px 34px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-mark {
  width: 46px; height: 46px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent);
  border: 1px solid rgba(227, 181, 108, 0.4);
  font-size: 24px;
}
.login-card h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: 0.06em; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.field input {
  width: 100%; height: 46px; padding: 0 14px;
  background: #0d1014; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.field input:focus { border-color: rgba(227, 181, 108, 0.65); box-shadow: 0 0 0 3px rgba(227, 181, 108, 0.08); }
.primary {
  width: 100%; height: 46px; border: 0; border-radius: 10px;
  background: var(--accent); color: #17130c; font-weight: 700; letter-spacing: 0.04em;
}
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: 0.55; cursor: default; }
.primary.small { width: auto; height: 36px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---------------- shell ---------------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 68px; display: flex; align-items: center; gap: 22px;
  padding: 0 clamp(16px, 3vw, 38px);
  background: rgba(11, 13, 16, 0.82);
  border-bottom: 1px solid rgba(38, 44, 54, 0.8);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: 0.08em; white-space: nowrap; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px rgba(227, 181, 108, 0.7); }
.search-wrap {
  flex: 1; max-width: 540px; position: relative;
}
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-51%); color: var(--muted-2); font-size: 18px; }
.search-wrap input {
  width: 100%; height: 40px; padding: 0 14px 0 40px;
  background: #0e1116; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; outline: none;
}
.search-wrap input:focus { border-color: rgba(227, 181, 108, 0.55); background: #10141a; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.ghost {
  height: 36px; padding: 0 13px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(22, 26, 32, 0.7);
  color: var(--text); font-size: 13px;
}
.ghost:hover { border-color: #3a4351; background: var(--card-hover); }
.ghost.subtle { color: var(--muted); }
.chip-button {
  height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px;
}
.chip-button:hover { color: var(--text); border-color: #3a4351; }

.shell {
  display: grid; grid-template-columns: 236px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 42px);
  max-width: 1580px; margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 38px) 60px;
}
.sidebar { position: sticky; top: 94px; align-self: start; min-height: calc(100vh - 130px); }
.side-block { margin-bottom: 26px; }
.side-block h3 {
  margin: 0 0 9px; padding: 0 10px;
  color: var(--muted-2); font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
}
.nav {
  width: 100%; height: 40px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 11px; margin-bottom: 3px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; text-align: left;
}
.nav:hover { background: rgba(255, 255, 255, 0.035); color: var(--text); }
.nav.active { background: var(--accent-soft); color: var(--accent); }
.nav-count { font-size: 12px; color: var(--muted-2); }
.nav.active .nav-count { color: rgba(227, 181, 108, 0.8); }
.album-list { display: flex; flex-direction: column; gap: 2px; }
.album-item {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-size: 13px; text-align: left;
}
.album-item:hover { background: rgba(255, 255, 255, 0.035); color: var(--text); }
.album-item.active { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.album-cover {
  width: 26px; height: 32px; flex: 0 0 26px; border-radius: 4px; object-fit: cover;
  background: #20252d; border: 1px solid rgba(255, 255, 255, 0.06);
}
.album-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-count { margin-left: auto; color: var(--muted-2); font-size: 11px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
.tag-chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 4px 9px; font-size: 12px;
}
.tag-chip:hover { color: var(--text); border-color: #3a4351; }
.tag-chip.active { background: var(--accent-soft); border-color: rgba(227, 181, 108, 0.4); color: var(--accent); }
.tag-chip .n { opacity: 0.55; margin-left: 4px; font-size: 10px; }
.side-foot { padding: 12px 10px; color: var(--muted-2); font-size: 11px; line-height: 1.6; }

.main { min-width: 0; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.main-head h1 { margin: 0 0 4px; font-size: clamp(22px, 2.5vw, 30px); font-weight: 600; letter-spacing: 0.02em; }
.main-head p { margin: 0; color: var(--muted); font-size: 13px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
}
.filter-pill button { border: 0; background: transparent; color: inherit; font-size: 15px; line-height: 1; padding: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 13px;
}
.card {
  position: relative; display: block; width: 100%; padding: 0; border: 0;
  border-radius: 12px; overflow: hidden; background: var(--card);
  aspect-ratio: 4 / 5; text-align: left;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}
.card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent 45%);
  opacity: 0.72; transition: opacity 0.2s;
}
.card:hover { transform: translateY(-2px); }
.card:hover::after { opacity: 0.95; }
.card img {
  width: 100%; height: 100%; display: block; object-fit: cover;
  transition: transform 0.35s ease, opacity 0.35s ease;
  background: #141820;
}
.card:hover img { transform: scale(1.035); }
.card .card-info {
  position: absolute; left: 11px; right: 11px; bottom: 9px; z-index: 2;
  display: flex; flex-direction: column; gap: 2px;
}
.card .card-name { font-size: 12px; color: #f4f1ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .card-album { font-size: 10px; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .card-heart {
  position: absolute; z-index: 3; top: 9px; right: 9px;
  width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(0, 0, 0, 0.4); color: var(--accent); font-size: 13px;
}
.card .card-tag {
  position: absolute; z-index: 3; top: 9px; left: 9px;
  max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 7px; border-radius: 5px; background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.78); font-size: 10px;
}
.empty { text-align: center; padding: 90px 20px; border: 1px dashed var(--line); border-radius: 16px; background: rgba(17, 20, 25, 0.5); }
.empty-mark { color: var(--accent); font-size: 38px; margin-bottom: 8px; }
.empty h2 { margin: 0 0 6px; font-size: 20px; font-weight: 500; }
.empty p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.empty .primary { width: auto; padding: 0 22px; }
.load-more { display: flex; justify-content: center; margin-top: 26px; }

/* ---------------- lightbox ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 6, 8, 0.96);
  display: grid; grid-template-columns: 54px minmax(0, 1fr) 54px;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
}
.lb-stage {
  grid-column: 2; grid-row: 1; position: relative;
  width: 100%; height: 100%; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 26px 8px 10px;
  background-size: contain; background-position: center; background-repeat: no-repeat;
}
.lb-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 4px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 0.25s;
}
.lb-stage img.loaded { opacity: 1; }
.lb-spinner {
  position: absolute; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.lb-error { color: var(--muted); text-align: center; font-size: 14px; line-height: 1.7; }
.lb-error span { color: var(--muted-2); font-size: 12px; }
.lb-close {
  position: fixed; top: 16px; right: 18px; z-index: 3;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(0, 0, 0, 0.35);
  color: #fff; font-size: 24px; line-height: 1;
}
.lb-nav {
  width: 42px; height: 64px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.035);
  color: #fff; font-size: 34px; line-height: 1;
}
.lb-prev { grid-column: 1; grid-row: 1; justify-self: center; }
.lb-next { grid-column: 3; grid-row: 1; justify-self: center; }
.lb-nav:hover { background: rgba(255, 255, 255, 0.09); }
.lb-info {
  grid-column: 2; grid-row: 2;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 24px; align-items: center;
  padding: 12px 14px 20px;
}
.lb-meta h2 { margin: 0 0 3px; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta p { margin: 0; color: var(--muted); font-size: 12px; }
.lb-tools { display: flex; gap: 8px; }
.lb-tag-editor { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
.lb-tags { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.lb-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; background: rgba(227, 181, 108, 0.1);
  color: var(--accent); font-size: 11px;
}
.lb-tag button { border: 0; background: transparent; color: inherit; padding: 0; font-size: 13px; }
.tag-input-row { display: flex; gap: 8px; }
.tag-input-row input {
  flex: 1; height: 36px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--line); background: #0e1116; color: var(--text); outline: none;
}
.tag-input-row input:focus { border-color: rgba(227, 181, 108, 0.55); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 200; padding: 10px 16px; border-radius: 9px;
  background: #f1eee7; color: #17130c; font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

/* ---------------- responsive ---------------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; gap: 20px; padding-top: 18px; }
  .sidebar { position: static; min-height: 0; }
  .side-block { margin-bottom: 16px; }
  .side-block h3 { padding: 0 4px; }
  .album-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .album-item { width: auto; min-width: 120px; background: rgba(255, 255, 255, 0.025); }
  .tag-cloud { padding: 0 2px; }
  .side-foot { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .lightbox { grid-template-columns: 42px minmax(0, 1fr) 42px; }
  .lb-nav { width: 34px; height: 52px; }
  .lb-info { padding: 10px 4px 18px; grid-template-columns: 1fr; }
  .lb-tools { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .brand { font-size: 15px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .top-actions { gap: 6px; }
  .top-actions .ghost { padding: 0 9px; font-size: 12px; }
  .shell { padding: 16px 12px 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { border-radius: 9px; }
  .card .card-info { left: 8px; right: 8px; bottom: 7px; }
  .main-head h1 { font-size: 22px; }
  .lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .lb-stage { grid-column: 1; grid-row: 1; padding: 10px 6px; }
  .lb-prev, .lb-next { position: fixed; top: 50%; z-index: 3; transform: translateY(-50%); }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
  .lb-info { grid-column: 1; grid-row: 2; padding: 10px 12px 18px; background: rgba(8, 9, 11, 0.92); }
  .lb-close { top: 10px; right: 10px; }
}
