:root {
  --ink: #151313;
  --muted: #746f68;
  --paper: #f6f1e9;
  --line: #dfd5c8;
  --seal: #9f2f24;
  --white: #fffaf2;
  --shadow: 0 18px 45px rgba(34, 28, 22, 0.14);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f5eee3;
  --muted: #b8aea1;
  --paper: #171412;
  --line: #3d352f;
  --white: #221d19;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(21, 19, 19, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #fbf8f1 0%, var(--paper) 100%);
  background-size: 44px 44px, auto;
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", serif;
}

html[data-theme="dark"] body {
  background:
    linear-gradient(90deg, rgba(255, 250, 242, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, #11100f 0%, var(--paper) 100%);
}

body.modal-open {
  overflow: hidden;
  scrollbar-gutter: stable;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  padding: 11px 18px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(18px, 5vw, 64px);
  background: rgba(251, 248, 241, 0.82);
  border-bottom: 1px solid rgba(223, 213, 200, 0.7);
  backdrop-filter: blur(18px);
}

html[data-theme="dark"] .site-header {
  background: rgba(18, 16, 15, 0.88);
  border-bottom-color: rgba(245, 238, 227, 0.12);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.seal {
  position: relative;
  display: inline-grid;
  grid-template-rows: repeat(2, 1fr);
  width: 46px;
  height: 46px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: #1b1714;
  color: #f1d5bd;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  box-shadow:
    inset 0 0 0 3px rgba(241, 213, 189, 0.08),
    0 10px 24px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.seal > span {
  position: relative;
  z-index: 1;
  display: block;
  letter-spacing: 0;
}

.seal::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(241, 213, 189, 0.24);
  border-radius: 5px;
}

.seal::after {
  content: none;
}

html[data-theme="dark"] .seal {
  background: #1b1714;
  color: #f1d5bd;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] .seal::before {
  border-color: rgba(241, 213, 189, 0.24);
}

.seal.big {
  width: 64px;
  height: 64px;
  font-size: 18px;
}

nav {
  align-items: center;
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.site-header nav a,
.theme-toggle {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(159, 47, 36, 0.35);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.68);
  color: var(--seal);
  font-family: "KaiTi", "STKaiti", serif;
  font-weight: 700;
}

.theme-toggle {
  width: 38px;
  padding: 0;
}

html[data-theme="dark"] .site-header nav a,
html[data-theme="dark"] .theme-toggle {
  background: rgba(245, 238, 227, 0.08);
  border-color: rgba(245, 238, 227, 0.18);
  color: #f1d5bd;
}

.hero {
  position: relative;
  min-height: min(620px, 78vh);
  display: grid;
  align-items: end;
  padding: clamp(22px, 6vw, 78px);
  overflow: hidden;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(251, 248, 241, 0.96), rgba(251, 248, 241, 0.5) 48%, rgba(251, 248, 241, 0.16));
  z-index: -1;
}

html[data-theme="dark"] .hero::after {
  background: linear-gradient(90deg, rgba(17, 16, 15, 0.94), rgba(17, 16, 15, 0.62) 50%, rgba(17, 16, 15, 0.22));
}

.hero-copy {
  max-width: 720px;
  padding-bottom: 24px;
}

.hero-copy p:first-child,
.section-head p,
.admin-top p {
  margin: 0 0 8px;
  color: var(--seal);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero-copy h1 {
  margin-bottom: 18px;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: clamp(54px, 11vw, 138px);
  line-height: 0.96;
  font-weight: 700;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 520px;
  color: #3f3932;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.8;
}

html[data-theme="dark"] .hero-copy p:last-child {
  color: #d4c8b8;
}

.gallery-wrap {
  padding: 44px clamp(18px, 5vw, 64px) 80px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  font-size: clamp(26px, 4vw, 42px);
  margin-bottom: 16px;
}

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

.post-card {
  background: rgba(255, 250, 242, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(34, 28, 22, 0.07);
  cursor: pointer;
}

html[data-theme="dark"] .post-card {
  background: rgba(34, 29, 25, 0.82);
}

.post-cover {
  position: relative;
}

.post-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e7ded1;
}

.image-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: rgba(21, 19, 19, 0.78);
  color: var(--white);
  padding: 4px 10px;
  font-size: 12px;
}

.post-card div {
  padding: 16px;
}

.post-card .post-cover {
  padding: 0;
}

.post-card h3 {
  margin-bottom: 8px;
}

.post-card p,
.viewer-meta p,
.hint {
  color: var(--muted);
  line-height: 1.7;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags span {
  border: 1px solid rgba(159, 47, 36, 0.28);
  color: var(--seal);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
}

.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 13px;
  background: rgba(18, 15, 13, 0.58);
}

.viewer-panel {
  position: relative;
  width: min(980px, calc(100vw - 26px));
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: calc(100vh - 26px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.viewer-stage {
  position: relative;
  background: #1c1713;
  touch-action: pan-y;
}

.viewer-stage img {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #1c1713;
  cursor: zoom-in;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 250, 242, 0.88);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  transform: translateY(-50%);
}

.viewer-nav.prev {
  left: 12px;
}

.viewer-nav.next {
  right: 12px;
}

.icon-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: rgba(21, 19, 19, 0.82);
  color: var(--white);
}

.viewer-meta {
  padding: 18px 20px 22px;
}

.viewer-thumbs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
}

.viewer-thumbs button {
  flex: 0 0 66px;
  height: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  background: transparent;
}

.viewer-thumbs button.active {
  border-color: var(--seal);
}

.viewer-thumbs img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fullscreen-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(12, 10, 9, 0.96);
  padding: 18px;
  overflow: hidden;
  touch-action: none;
}

.fullscreen-viewer img {
  width: auto;
  height: auto;
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 36px);
  object-fit: contain;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transform: translate(0, 0) scale(1);
  transform-origin: center center;
  will-change: transform;
}

.fullscreen-viewer img.dragging {
  cursor: grabbing;
}

.fullscreen-viewer .icon-close {
  position: fixed;
  top: 16px;
  right: 16px;
}

.fullscreen-viewer .viewer-nav {
  position: fixed;
}

.admin-body {
  min-height: 100vh;
  background: #f4efe6;
}

.admin-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.admin-side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #171413;
  color: var(--white);
}

.admin-side .brand {
  margin-bottom: 34px;
}

.tab,
.ghost {
  width: 100%;
  margin-bottom: 10px;
  background: transparent;
  color: inherit;
  border: 1px solid rgba(255, 250, 242, 0.2);
  text-align: left;
}

.tab.active {
  background: rgba(255, 250, 242, 0.12);
  border-color: rgba(255, 250, 242, 0.42);
}

.login-panel {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.admin-main {
  padding: 30px clamp(20px, 4vw, 48px);
}

.hidden,
.tab-page {
  display: none !important;
}

.tab-page.active {
  display: block !important;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 14px 34px rgba(34, 28, 22, 0.08);
}

.panel.narrow {
  width: min(440px, 100%);
}

.editor {
  margin-bottom: 22px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
  color: #403934;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--seal);
  box-shadow: 0 0 0 3px rgba(159, 47, 36, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr auto;
  gap: 16px;
  align-items: center;
}

.upload-box {
  min-height: 116px;
  place-items: center;
  border: 1px dashed rgba(159, 47, 36, 0.48);
  border-radius: 8px;
  color: var(--seal);
  cursor: pointer;
}

.upload-box input {
  display: none;
}

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

.preview-grid .hint {
  margin: 0;
}

.preview-tile {
  position: relative;
  margin: 0;
}

.preview-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-tile button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: rgba(21, 19, 19, 0.82);
}

.preview-tile figcaption {
  position: absolute;
  left: 6px;
  bottom: 6px;
  border-radius: 999px;
  background: var(--seal);
  color: var(--white);
  padding: 2px 7px;
  font-size: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check input {
  width: auto;
}

.actions {
  display: flex;
  gap: 10px;
}

.actions .ghost,
.link-btn {
  width: auto;
  color: var(--ink);
  border-color: var(--line);
}

.admin-posts {
  display: grid;
  gap: 12px;
}

.admin-item {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 16px;
  align-items: center;
  background: rgba(255, 250, 242, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.admin-item img {
  width: 96px;
  height: 76px;
  object-fit: cover;
  border-radius: 6px;
}

.admin-item h3 {
  margin-bottom: 4px;
}

.admin-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.item-actions {
  display: flex;
  gap: 8px;
}

.item-actions button {
  padding: 8px 12px;
}

.item-actions .ghost {
  color: var(--ink);
  border-color: var(--line);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .site-header,
  .admin-top,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .hero {
    min-height: 560px;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-side {
    position: static;
    height: auto;
  }

  .form-grid,
  .upload-row,
  .admin-item {
    grid-template-columns: 1fr;
  }

  .admin-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}
