/* ==========================================================================
   观·藏密壁画 — design tokens & shell
   设计基准：1920×1080（MasterGo），PingFang SC
   ========================================================================== */

:root {
  /* color */
  --bg: #000000;
  --bg-raise: #1A1A1A;
  --ink: #FFFFFF;
  --ink-80: rgba(255, 255, 255, .8);
  --ink-60: rgba(255, 255, 255, .6);
  --ink-50: rgba(255, 255, 255, .5);
  --ink-40: rgba(255, 255, 255, .4);
  --ink-30: rgba(255, 255, 255, .3);
  --ink-20: rgba(255, 255, 255, .2);
  --ink-10: rgba(255, 255, 255, .1);
  --ink-06: rgba(255, 255, 255, .06);
  --glass: rgba(255, 255, 255, .1);
  --glass-hover: rgba(255, 255, 255, .17);
  --glass-active: rgba(255, 255, 255, .24);
  /* effect_13:6848 设计稿玻璃效果 */
  --glass-blur: blur(20px) saturate(140%);
  --danger: #FF4D4F;
  --req: #FF0000;

  /* radius */
  --r-pill: 100px;
  --r-lg: 20px;
  --r-md: 8px;
  --r-sm: 4px;

  /* layout */
  --nav-h: 80px;
  --pad-x: 48px;
  --card-w: 480px;
  --card-gap: 10px;

  /* type */
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", system-ui, -apple-system, sans-serif;

  /* motion */
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-in-out: cubic-bezier(.65, .05, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.35, .44, 1);
  --dur-1: .22s;
  --dur-2: .38s;
  --dur-3: .58s;
  --dur-4: .86s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
/* 视口比设计稿窄时横向可滚，不做缩小 */
html { overflow-x: auto; overflow-y: hidden; }

body {
  /* 设计基准 1440：1 设计 px = 1 CSS px，不缩放；窄于 800 时横向滚动 */
  position: relative;
  width: 100%;
  min-width: 800px;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(110% 90% at 50% 42%, #1A1A1A 0%, #0a0a0a 55%, #000 100%);
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: rgba(255, 255, 255, .22); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; display: block; }
.ico--16 { width: 16px; height: 16px; }
.ico--20 { width: 20px; height: 20px; }
.ico--24 { width: 24px; height: 24px; }
.ico--28 { width: 28px; height: 28px; }
.ico--40 { width: 40px; height: 40px; opacity: .35; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 10px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  /* 设计稿 47:08574：左右 48 安全边距 */
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  column-gap: 24px;
  z-index: 60;
  pointer-events: none;
  /* 导航固定在视口上：点按时的横向抖动不允许带动整页横向平移，
     否则一点 tab 整个舞台就被推走、竖轨也滑出屏幕 */
  touch-action: pan-y;
}
/* touch-action 不继承且固定定位下祖先值不生效，交互元素上要各自声明 */
.nav button,
.nav a,
.nav input { touch-action: pan-y; }
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  z-index: -1;
}
.nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 40px;
  background: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .8) 50%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}
.nav__left { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 0 1 auto; pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand__logo { width: 32px; height: 32px; object-fit: contain; flex: none; }
.brand__name {
  flex: none;
  font-size: 20px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: .01em;
  white-space: nowrap;
  word-break: keep-all;
}

.nav__tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

/* 导航搜索（壁画 / 寺庙 tab）：200×36 胶囊，#1A1A1A，16 图标 + 14 文字 */
.nav-search {
  display: none;
  align-items: center;
  gap: 4px;
  flex: none;
  width: 200px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: #1A1A1A;
  pointer-events: auto;
}
body[data-tab="mural"] .nav-search,
body[data-tab="temple"] .nav-search { display: flex; }
.nav-search__ico {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  opacity: .5;
}
.nav-search__ico::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 8.4px;
  height: 8.4px;
  border: 1.2px solid #fff;
  border-radius: 50%;
}
.nav-search__ico::after {
  content: "";
  position: absolute;
  left: 9.6px;
  top: 9px;
  width: 5px;
  height: 1.2px;
  border-radius: 1px;
  background: #fff;
  transform: rotate(45deg);
  transform-origin: left center;
}
.nav-search__input {
  flex: 1;
  min-width: 0;
  height: 20px;
  padding: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
}
.nav-search__input::placeholder { color: var(--ink); opacity: .5; }
.nav-search__input::-webkit-input-placeholder { color: var(--ink); opacity: .5; }
.nav__tabs::-webkit-scrollbar { display: none; }
.nav__tab {
  position: relative;
  z-index: 1;
  height: 38px;
  padding: 8px 20px;
  border-radius: var(--r-pill);
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease-out), background-color var(--dur-2) var(--ease-out), opacity var(--dur-1);
}
.nav__tab:hover { opacity: .8; }
.nav__tab.is-active { color: var(--ink); background: transparent; opacity: 1; }
.nav__glider {
  position: absolute;
  top: 0;
  left: 0;
  height: 38px;
  border-radius: var(--r-pill);
  background: var(--glass);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), inset 0 1px 0 rgba(255, 255, 255, .16);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: transform var(--dur-3) var(--ease-spring), width var(--dur-3) var(--ease-spring);
  pointer-events: none;
}
body.is-booting .nav__glider { transition: none; }

/* 切换 tab 时玻璃框描边「放大再收回」 */
.nav__glider-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, .6);
  opacity: 0;
  pointer-events: none;
}
.nav__glider.is-pulse .nav__glider-ring {
  animation: gliderPulse .66s var(--ease-out) both;
}
@keyframes gliderPulse {
  0% { transform: scale(1); opacity: .55; }
  46% { transform: scale(1.09); opacity: .34; }
  100% { transform: scale(1); opacity: 0; }
}

/* glass buttons */
.btn-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 8px 24px;
  border-radius: var(--r-pill);
  background: var(--glass);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), inset 0 1px 0 rgba(255, 255, 255, .16);
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: background-color var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
.btn-glass:hover { background: var(--glass-hover); }
.btn-glass:active { transform: scale(.97); background: var(--glass-active); }
.btn-glass--quiet { color: var(--ink-80); }
.btn-glass--danger { background: rgba(255,77,79,.16); }
.btn-glass--danger:hover { background: rgba(255,77,79,.28); }
/* 右侧操作组：搜索 + 下载 + 录入，设计稿 47:08053 间距 16、高 36 */
.nav__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
  pointer-events: auto;
}
.btn-enter {
  flex: none;
  pointer-events: auto;
  height: 36px;
  padding: 8px 20px;
  gap: 4px;
  font-size: 14px;
  line-height: 20px;
  /* 设计稿 47:08640：1px 20% 白描边胶囊，无底色 */
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.btn-enter:hover { background: rgba(255, 255, 255, .06); }
.btn-enter:active { background: rgba(255, 255, 255, .12); }
.btn-enter .ico { width: 14px; height: 14px; }
/* 下载：设计稿 47:08053 —— 1px 20% 白描边胶囊，无底色 */
.btn-export {
  flex: none;
  pointer-events: auto;
  height: 36px;
  padding: 8px 20px;
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 14px;
  line-height: 20px;
}
.btn-export:hover { background: rgba(255, 255, 255, .06); }
.btn-export:active { background: rgba(255, 255, 255, .12); }
.btn-export[disabled] { opacity: .45; pointer-events: none; }

/* 窄窗：导航三块继续均布，收紧 tab / 按钮的横向留白，保证 tab 与右侧按钮同时可见 */
@media (max-width: 1100px) {
  .nav__tab { padding-left: 12px; padding-right: 12px; }
  .nav__left { gap: 16px; }
  .btn-enter { padding-left: 16px; padding-right: 16px; }
}
/* 视口小于 800（内容保留 800 最小宽横向滚动）时，导航固定在视口上，
   右侧「录入」按钮始终贴视口右缘 48px，不被 body 最小宽挤出屏幕 */
@media (max-width: 799px) {
  .nav { position: fixed; }
}
/* 手机视口：导航两侧 48px 安全边距 + 品牌文字会把 tab 条压成 0 宽，
   收紧边距、只留 logo、tab 条占剩余空间并可横滑 */
@media (max-width: 799px) {
  .nav { padding: 0 12px; column-gap: 8px; }
  .brand__name { display: none; }
  .nav__left { flex: 1 1 auto; gap: 8px; }
  /* 5 个 tab 平分剩余宽度：等分后「寺庙 / 壁画」不会被挤出可视区，
     也不会被右侧「录入」按钮压住导致点错 */
  .nav__tabs { flex: 1 1 auto; gap: 0; }
  .nav__tab { flex: 1 1 0; padding-left: 0; padding-right: 0; }
  .nav__actions { gap: 8px; }
  .nav__actions .btn-glass { padding-left: 14px; padding-right: 14px; }
  /* 手机宽度下「筛选」固定收成一枚胶囊，并在所有 tab 上占位（壁画 tab 才可见），
     这样切到壁画时 tab 条不会突然缩短、把按钮挪到手指下面 */
  .nav .nav__filters { display: flex; visibility: hidden; }
  .nav__filters .filter { display: none !important; }
  .nav__filters .nav__filter-toggle { display: flex; }
  body[data-tab="mural"] .nav__filters { visibility: visible; }
  /* 手机宽度下「录入」收成图标按钮，把宽度让给 tab */
  .nav__actions .btn-enter { width: 36px; padding-left: 0; padding-right: 0; justify-content: center; }
  .btn-enter #enterLabel { display: none; }
  .nav-search { display: none !important; }
  /* 手机宽度下优先保证 tab 与「录入」，导出走桌面端 */
  .btn-export { display: none; }
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-80);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1), transform var(--dur-2) var(--ease-spring);
}
.btn-icon:hover { background: var(--ink-10); color: var(--ink); }
.btn-icon:active { transform: scale(.92); }

/* ==========================================================================
   可搜索下拉（弹窗选择器 / 壁画导航筛选共用）
   设计稿 47:08053 组 298 · 320×344 · 渐变 #1A1A1A→#0D0D0D · 1px #333 · r8
   搜索框 304×40 r4 · 选项行 304×40 · 文字 14/20 · 选中行 r4
   ========================================================================== */
.sel-pop {
  position: fixed;
  z-index: 300;
  padding: 8px;
  border-radius: 8px;
  background: linear-gradient(180deg, #1A1A1A 0%, #0D0D0D 100%);
  box-shadow: inset 0 0 0 1px #333, 0 24px 60px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.sel-pop.is-open { opacity: 1; transform: none; }
.sel-pop__search {
  position: relative;
  height: 40px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .5);
  overflow: hidden;
}
.sel-pop__input {
  width: 100%;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
}
.sel-pop__input::placeholder { color: rgba(255, 255, 255, .3); }
.sel-pop__list {
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
  /* 人物/寺庙可达上百项，保留细滚动条提示还有更多选项 */
  padding-right: 4px;
}
.sel-pop__list::-webkit-scrollbar { width: 6px; height: 6px; }
.sel-pop__list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 10px; }
.sel-pop__opt {
  display: flex;
  align-items: center;
  width: 100%;
  height: 40px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 20px;
  color: rgba(255, 255, 255, .5);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color var(--dur-1), color var(--dur-1), border-radius var(--dur-1);
}
.sel-pop__opt:hover,
.sel-pop__opt.is-cursor { background: rgba(255, 255, 255, .05); color: var(--ink); }
.sel-pop__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sel-pop__count { flex: none; margin-left: 12px; font-size: 12px; color: rgba(255, 255, 255, .3); font-variant-numeric: tabular-nums; }
.sel-pop__opt.is-active .sel-pop__count { color: rgba(255, 255, 255, .5); }
.sel-pop__opt.is-active { background: rgba(255, 255, 255, .05); color: var(--ink); border-radius: 4px; }
.sel-pop__empty {
  padding: 16px 12px;
  font-size: 14px;
  line-height: 20px;
  color: rgba(255, 255, 255, .3);
  text-align: center;
}

/* ==========================================================================
   Stage & views
   ========================================================================== */

.stage { position: absolute; inset: 0; overflow: hidden; }

.view {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 18px, 0);
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out),
    visibility 0s linear var(--dur-3);
  will-change: opacity, transform;
}
.view.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out),
    visibility 0s;
}
.view.is-leaving { transform: translate3d(0, -10px, 0); }

/* entrance stagger helper */
.view.is-active .rise { animation: riseIn var(--dur-3) var(--ease-out) both; }
@keyframes riseIn {
  from { opacity: 0; transform: translate3d(0, 26px, 0); }
  to { opacity: 1; transform: none; }
}

/* empty / loading */
.state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  color: var(--ink-50);
  padding: 0 24px;
  z-index: 3;
}
.state__title { margin: 0; font-size: 28px; font-weight: 500; color: var(--ink-80); letter-spacing: .02em; }
.state__text { margin: 0; font-size: 16px; line-height: 26px; max-width: 460px; }
.state__hint { margin: 0; font-size: 14px; color: var(--ink-30); }
.state .btn-glass { margin-top: 10px; height: 44px; font-size: 16px; }

/* skeleton shimmer */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.04);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  animation: shimmer 1.8s var(--ease-in-out) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translate3d(-50%, 24px, 0);
  padding: 12px 22px;
  border-radius: var(--r-pill);
  background: rgba(26,26,26,.92);
  border: 1px solid var(--ink-10);
  backdrop-filter: blur(18px);
  font-size: 14px;
  color: var(--ink-80);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
.toast.is-show { opacity: 1; transform: translate3d(-50%, 0, 0); }

/* 同步状态提示条：只在本地文件模式或保存失败时出现 */
.sync-warning {
  position: fixed;
  left: 50%;
  top: 96px;
  transform: translate3d(-50%, -12px, 0);
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: rgba(64, 24, 24, .88);
  border: 1px solid rgba(255, 120, 120, .32);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-size: 13px;
  line-height: 20px;
  color: rgba(255, 240, 240, .92);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
/* 提示条只让自身按钮可点，整条胶囊不得吞掉页面点击（弹窗内的删除按钮等） */
.sync-warning.is-on { opacity: 1; transform: translate3d(-50%, 0, 0); }
.sync-warning.is-on .sync-warning__link,
.sync-warning.is-on .sync-warning__retry { pointer-events: auto; }
.sync-warning__link,
.sync-warning__retry {
  flex: none;
  font: inherit;
  color: #fff;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, .5);
}
.sync-warning__link:hover,
.sync-warning__retry:hover { border-bottom-color: #fff; }

/* utility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}