:root {
  --bg: #f4f2ed;
  --panel: #ffffff;
  --text: #19202a;
  --muted: #68707c;
  --line: #ded8ce;
  --accent: #bf2838;
  --accent-dark: #8e1724;
  --ink: #11151b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 242, 237, .94);
  backdrop-filter: blur(14px);
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; }
#pageMeta, .admin-head p { color: var(--muted); margin-top: 6px; }

main { padding: 24px 28px 80px; }

.home-tools {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.search-box {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  max-width: 560px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 14px;
}

.search-box span { color: var(--muted); }
.search-box input, .full-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 11px 12px;
  font-size: 16px;
  outline: none;
  background: #fff;
}
.search-box input { border: 0; padding: 0; }

.letters {
  position: sticky;
  top: 84px;
  z-index: 18;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0;
  background: rgba(244, 242, 237, .96);
  backdrop-filter: blur(12px);
}

.letters button, .plain-button, .back-button, .tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 11px;
  border-radius: 4px;
  cursor: pointer;
}
.letters button.active, .tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

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

.album-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.album-card:hover { border-color: #b9aea0; }

.cover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  aspect-ratio: 2 / 1.15;
  overflow: hidden;
  background: #eee;
}
.cover-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.album-info {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 2px 2px;
}
.album-name { font-size: 18px; font-weight: 800; }
.album-count { color: var(--muted); white-space: nowrap; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.photo-card {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px;
  border-radius: 6px;
  overflow: hidden;
}
.photo-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: #eee;
}
.gallery-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  padding: 5px 8px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.add-photo {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 0;
  background: var(--ink);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0,0,0,.25);
}
.add-photo.selected { background: var(--accent); }

.float-actions {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
  justify-items: end;
}
.float-button {
  border: 0;
  background: var(--ink);
  color: #fff;
  min-width: 48px;
  height: 48px;
  border-radius: 999px;
  padding: 0 15px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}
.cart-float span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  background: var(--accent);
  border-radius: 999px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 21, 27, .56);
}
.modal {
  width: min(720px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 55px rgba(0,0,0,.32);
}
.small-modal { width: min(420px, 100%); display: grid; gap: 14px; }
.modal-head, .admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.primary-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button:hover { background: var(--accent-dark); }

.cart-list { display: grid; gap: 8px; margin-bottom: 16px; }
.cart-phone {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}
.cart-phone span { color: var(--muted); }
.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}
.captcha-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.captcha-row img {
  width: 160px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.submit-msg { color: var(--muted); margin-top: 10px; }

.status-modal {
  justify-items: center;
  text-align: center;
}
.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 5px solid #e6e0d7;
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.success-check {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  font-size: 38px;
  font-weight: 900;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pswp-caption-cart {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 100000;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(520px, calc(100vw - 32px));
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(17, 21, 27, .82);
  color: #fff;
  font-weight: 800;
}
.pswp-cart-button {
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  padding: 9px 12px;
  font-weight: 800;
  cursor: pointer;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,.9);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 18px;
}
.lightbox button {
  justify-self: end;
  border: 1px solid rgba(255,255,255,.4);
  background: transparent;
  color: #fff;
  border-radius: 4px;
  padding: 8px 12px;
}
.lightbox img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  justify-self: center;
  align-self: center;
}
.lightbox p { color: #fff; text-align: center; }

.admin-body { background: #eef0f2; }
.admin-shell { max-width: 1180px; margin: 0 auto; }
.admin-login {
  width: min(380px, calc(100vw - 32px));
  margin: 14vh auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 14px;
}
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.admin-table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 2.4fr 1.2fr 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  min-width: 940px;
}
.row.header { font-weight: 800; background: #f8f8f8; }
.row textarea, .row input, .row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px;
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .topbar { padding: 14px 16px; }
  main { padding: 18px 14px 86px; }
  h1 { font-size: 23px; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .captcha-row { grid-template-columns: 1fr; }
  .search-box { grid-template-columns: 1fr; gap: 8px; }
}
