@font-face {
  font-family: "万事全兴体";
  src: url("/tools/card_generator/fonts/%E4%B8%87%E4%BA%8B%E5%85%A8%E5%85%B4%E4%BD%93.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* 配色 1 暮山青（默认，深色值） */
  --background: #242a28;
  --background-light: #f5f1e8;
  --panel: #2e3634;
  --panel-light: #fffdf8;
  --text: #ece9e2;
  --text-light: #2b302d;
  --accent: #93b8a6;
  --accent-light: #55786a;
  --muted: #8b938f;
  --muted-light: #948d82;
  --border: #3a4441;
  --border-light: #e5ddd0;
  --overlay: rgba(20, 24, 23, .9);
  --overlay-light: rgba(245, 241, 232, .94);
  --dash: var(--accent);
  --dash-light: var(--accent-light);
  --header-font: "Racing Sans One", "万事全兴体", "Segoe UI", sans-serif;
  --body-font: "Josefin Sans", "Microsoft YaHei", sans-serif;
}

html[data-theme="1"] {
  /* 暮山青：深灰绿 + 鼠尾草 */
}

html[data-theme="2"] {
  /* 海盐雾：雾蓝灰 + 海盐青 */
  --background: #1f2a31;
  --background-light: #eef4f6;
  --panel: #28343d;
  --panel-light: #ffffff;
  --text: #e8eef2;
  --text-light: #22303a;
  --accent: #7fb8c9;
  --accent-light: #39768f;
  --muted: #7f8f99;
  --muted-light: #8b9aa3;
  --border: #36454f;
  --border-light: #d7e3e8;
  --overlay: rgba(15, 22, 27, .9);
  --overlay-light: rgba(238, 244, 246, .94);
}

html[data-theme="3"] {
  /* 柑橘茶：暖褐 + 琥珀 */
  --background: #2a2320;
  --background-light: #fdf6ec;
  --panel: #352c27;
  --panel-light: #fffdf9;
  --text: #f0e9e2;
  --text-light: #332a24;
  --accent: #d9a564;
  --accent-light: #a86e2f;
  --muted: #a08f83;
  --muted-light: #a29386;
  --border: #453a33;
  --border-light: #eadfce;
  --overlay: rgba(26, 21, 18, .9);
  --overlay-light: rgba(253, 246, 236, .95);
}

html[data-theme="4"] {
  /* 雾紫夜：梅子黑 + 淡紫 */
  --background: #241f2e;
  --background-light: #f6f2f9;
  --panel: #2e2839;
  --panel-light: #ffffff;
  --text: #ece8f2;
  --text-light: #2d2738;
  --accent: #b3a2d6;
  --accent-light: #74629f;
  --muted: #8f879f;
  --muted-light: #a297ad;
  --border: #3b3447;
  --border-light: #e4dcee;
  --overlay: rgba(19, 16, 26, .9);
  --overlay-light: rgba(246, 242, 249, .94);
}

html[data-theme="5"] {
  /* 森雾：苔藓绿 + 柔和绿 */
  --background: #1f2722;
  --background-light: #f0f4ee;
  --panel: #28342d;
  --panel-light: #ffffff;
  --text: #e9efe9;
  --text-light: #27302a;
  --accent: #94b99d;
  --accent-light: #4f7d5e;
  --muted: #84948a;
  --muted-light: #97a29a;
  --border: #37443b;
  --border-light: #dce5da;
  --overlay: rgba(16, 22, 19, .9);
  --overlay-light: rgba(240, 244, 238, .95);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html.light { color-scheme: light; }
html:not(.light) { color-scheme: dark; }

body {
  background: var(--background);
  color: var(--text);
  font-family: var(--body-font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 24px 10px;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-name {
  font-family: var(--header-font);
  font-size: 1.7rem;
  color: var(--text);
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
}

.head-nav { display: flex; align-items: center; gap: 18px; }
.weibo-link {
  display: flex;
  align-items: center;
  color: var(--accent);
  text-decoration: none;
  transition: color .3s, transform .3s, filter .3s;
}
.weibo-link svg { width: 22px; height: 22px; display: block; }
.weibo-link #形状 { fill: currentColor; }
.weibo-link #MingCute { fill: none; }
.weibo-link:hover { transform: translateY(-1px); filter: brightness(1.15); }

.theme-btn {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: rotate .3s;
}
.theme-btn:hover { rotate: 10deg; }
.theme-btn .moon { fill: var(--text); }
.theme-btn .sun,
.light .theme-btn .moon { fill: transparent; }
.light .theme-btn .sun { fill: var(--text-light); }

/* 移动端禁止双击缩放：可交互元素上声明 manipulation */
.back-btn, .theme-btn, .weibo-link, .journal-card, .gallery-item, .sheet-toggle,
.detail-link, .close-btn, .nav-btn, .ctrl-btn, .ctrl-close, .model-btn { touch-action: manipulation; }

.container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 24px 60px;
}

.page-intro { margin-bottom: 34px; }
.page-title {
  font-family: var(--header-font);
  font-size: 2.6rem;
  font-weight: 400;
  margin-bottom: 6px;
}
.page-sub { color: var(--muted); font-size: 15px; }

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

.journal-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: transform .35s cubic-bezier(.175,.885,.32,1.275), box-shadow .35s;
  animation: rise .5s ease both;
}
.journal-card:nth-child(2) { animation-delay: .08s; }
.journal-card:nth-child(3) { animation-delay: .14s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.journal-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 34px rgba(0,0,0,.3);
}

.journal-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: transparent;
}

.journal-body { padding: 18px 20px 20px; position: relative; }
.journal-body h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.journal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.journal-title-row h2 { margin-bottom: 0; }
.journal-logo {
  height: 38px;
  width: auto;
  max-width: 42%;
  object-fit: contain;
  flex-shrink: 0;
}
.journal-desc {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  min-height: 21px;
}
.journal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1.5px dashed var(--dash);
}
.journal-count {
  font-size: 12px;
  color: var(--accent);
}
.stamp-mini {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 2px 12px;
  transform: rotate(-4deg);
}

.view-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
  animation: fade .4s ease both;
}
.back-btn {
  background: none;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: var(--body-font);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .35s, color .35s;
}
.back-btn:hover { background: var(--accent); color: var(--text-light); }
.album-title { font-family: var(--header-font); font-size: 2rem; font-weight: 400; }
.album-count { color: var(--muted); font-size: 13px; }

.justified-box { animation: fade .4s ease both; }
.justified-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.gallery-item {
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  background: transparent;
  transition: filter .3s, transform .3s;
}
.gallery-item:hover { filter: brightness(1.12); transform: scale(1.015); }
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.item-title {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 24px 12px 9px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #fff;
  font-size: 13px;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.gallery-item:hover .item-title,
.gallery-item:focus-within .item-title { opacity: 1; }

.type-badge {
  position: absolute;
  top: 8px; right: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--accent);
  color: var(--text-light);
  pointer-events: none;
}
.light .type-badge { color: #fff; }

.gallery-loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 14px;
}
.gallery-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 15px;
}
.paintings-sentinel {
  text-align: center;
  padding: 22px 16px 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.paintings-sentinel.sentinel-error { color: #c33; }

.site-foot {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}
.site-foot a { color: var(--accent); text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }
.site-foot .weibo-link { display: inline-flex; align-items: center; gap: 7px; }
.site-foot .weibo-link svg { width: 19px; height: 19px; }
.site-foot .weibo-link .foot-handle { font-size: 13px; }
.site-foot .weibo-link:hover { text-decoration: none; }
.site-foot .weibo-link:hover .foot-handle { text-decoration: underline; }

/* ===== 详情浮层 ===== */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  display: flex;
  animation: fade .25s ease both;
}
.detail-overlay[hidden] { display: none; }

.detail-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.detail-figure {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 86px 18px;
  position: relative;
}
.detail-figure img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ===== 3D 模型查看器 ===== */
.model-viewport {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: min(80vw, 80vh, 1000px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 10px 60px rgba(0,0,0,.5);
}
.model-viewport canvas { display: block; }
.model-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 15px;
  z-index: 5;
  border-radius: 16px;
}
.model-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}
.model-btn {
  width: 36px; height: 36px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: rgba(30, 30, 46, .7);
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color .4s, color .4s;
}
.model-btn:hover { background-color: var(--accent); color: var(--text-light); }
.model-btn:disabled { opacity: .3; cursor: default; }
.model-btn:disabled:hover { background: rgba(30, 30, 46, .7); color: var(--accent); }

.detail-controls { display: none; }
.ctrl-btn {
  width: 40px; height: 40px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color .3s, color .3s;
}
.ctrl-btn:hover { background: var(--accent); color: var(--text-light); }
.ctrl-btn:disabled { opacity: .25; cursor: default; }
.ctrl-counter { font-size: 13px; letter-spacing: 2px; color: var(--muted); min-width: 52px; text-align: center; }
/* 关闭按钮：独立实底圆形，与翻页/计数区分 */
.ctrl-close {
  width: 40px; height: 40px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-light);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter .3s, background-color .3s, color .3s;
}
.ctrl-close:hover { filter: brightness(1.1); }

.detail-sheet {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 18px 28px 22px;
  width: var(--sheet-w, 100%);
  margin: 0 auto;
  max-height: 42vh;
  overflow-y: auto;
  transition: transform .35s ease;
}
.detail-sheet.collapsed .detail-desc,
.detail-sheet.collapsed .detail-links { display: none; }
.detail-sheet.collapsed { max-height: none; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.detail-title {
  font-family: var(--header-font);
  font-size: 1.7rem;
  font-weight: 400;
}
.detail-date { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sheet-toggle {
  flex-shrink: 0;
  background: none;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.sheet-toggle:hover { background: var(--accent); color: var(--text-light); }

.detail-desc {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--text);
  padding-top: 14px;
}
.detail-desc p { margin-bottom: 10px; }
.detail-desc:empty { display: none; }
.detail-links {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}
.detail-links:empty { display: none; }
.detail-link {
  display: inline-block;
  margin: 0 12px 8px 0;
  padding: 8px 18px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .35s, color .35s;
}
.detail-link:hover { background: var(--accent); color: var(--text-light); }

.close-btn, .nav-btn {
  position: fixed;
  z-index: 10001;
  background: none;
  color: var(--accent);
  cursor: pointer;
  transition: background-color .3s, color .3s;
}
.close-btn {
  top: var(--close-top, 18px);
  right: var(--close-right, 22px);
  width: 44px; height: 44px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn {
  top: var(--nav-top, 50%);
  transform: translateY(-50%);
  width: 46px; height: 78px;
  border: 2px solid var(--accent);
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.prev-btn { left: var(--nav-l, 14px); border-radius: 8px; }
.next-btn { right: var(--nav-r, 14px); border-radius: 8px; }
.close-btn:hover, .nav-btn:hover { background: var(--accent); color: var(--text-light); }
.nav-btn:disabled { opacity: .25; cursor: default; }
.nav-btn:disabled:hover { background: none; color: var(--accent); }

/* ===== 亮色主题 ===== */
.light body { background: var(--background-light); color: var(--text-light); }
.light .brand-name, .light .page-title, .light .album-title { color: var(--text-light); }
.light .brand-sub, .light .page-sub, .light .journal-desc, .light .album-count, .light .detail-date { color: var(--muted-light); }
.light .weibo-link, .light .site-foot a { color: var(--accent-light); }
.light .journal-card { background: var(--panel-light); border-color: var(--border-light); box-shadow: 0 6px 22px rgba(80,90,90,.1); }
.light .journal-card:hover { box-shadow: 0 12px 34px rgba(80,90,90,.18); }
.light .journal-foot { border-top-color: var(--dash-light); }
.light .journal-count { color: var(--accent-light); }
.light .stamp-mini { color: var(--accent-light); border-color: var(--accent-light); }
.light .back-btn { color: var(--accent-light); border-color: var(--accent-light); }
.light .back-btn:hover { background: var(--accent-light); color: var(--text); }
.light .gallery-item { background: transparent; }
.light .view-head { border-bottom-color: var(--border-light); }
.light .detail-overlay { background: var(--overlay-light); }
.light .detail-sheet { background: var(--panel-light); border-top-color: var(--border-light); }
.light .detail-link, .light .close-btn, .light .nav-btn, .light .sheet-toggle { color: var(--accent-light); border-color: var(--accent-light); }
.light .detail-link:hover, .light .close-btn:hover, .light .nav-btn:hover, .light .sheet-toggle:hover { background: var(--accent-light); color: var(--text); }
.light .nav-btn:disabled:hover { background: none; color: var(--accent-light); }
.light .detail-links { border-top-color: var(--border-light); }
.light .detail-desc { color: var(--text-light); }
.light .model-viewport { background: var(--panel-light); }
.light .model-loading { background: var(--panel-light); color: var(--text-light); }
.light .model-btn { background: rgba(255,255,255,.8); color: var(--accent-light); border-color: var(--accent-light); }
.light .model-btn:hover { background-color: var(--accent-light); color: var(--text); }
.light .model-btn:disabled:hover { background: rgba(255,255,255,.8); color: var(--accent-light); }
.light .ctrl-btn { color: var(--accent-light); border-color: var(--accent-light); }
.light .ctrl-btn:hover { background: var(--accent-light); color: var(--text); }
.light .ctrl-btn:disabled:hover { background: none; color: var(--accent-light); }
.light .ctrl-counter { color: var(--muted-light); }
.light .ctrl-close { background: var(--accent-light); color: var(--text); border-color: var(--accent-light); }
.light .ctrl-close:hover { filter: brightness(1.1); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .site-head { padding: 20px 14px 8px; }
  .head-nav { gap: 10px; }
  .container { padding: 22px 10px 44px; }
  .page-title { font-size: 2rem; }
  .album-grid { grid-template-columns: 1fr; gap: 16px; }
  .view-head { flex-wrap: wrap; gap: 10px; }
  .album-title { font-size: 1.5rem; }
  .detail-figure { padding: 62px 14px 10px; }
  .nav-btn { display: none; }
  .detail-controls { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 0 16px 14px; }
  .detail-sheet { width: 100%; max-width: 100%; padding: 14px 16px 18px; max-height: 48vh; }
  .close-btn { top: 12px; right: 12px; }
  .model-viewport { max-width: 88vw; }
  .site-foot { flex-direction: column; align-items: center; gap: 6px; }
}
