/* 喵星 Miaostar：手绘田园风，柔和的天色与纸色，和城镇水彩一致。 */
:root {
  --sky-top: #cfe6ef;
  --sky-mid: #e4efe6;
  --sky-bottom: #f3efe4;
  --paper: #f8f4ea;
  --paper-deep: #efe8d8;
  --ink: #3d4a3a;
  --soft-ink: #6b7a68;
  --accent: #5a8f7b;
  --accent-warm: #d4895a;
  --star: #5a8f7b;
  --line: rgba(61, 74, 58, 0.14);
  --night: #3d4a3a;
  --night-deep: #2a3328;
  --font-display: 'Fraunces', 'Noto Serif SC', 'Songti SC', serif;
  --font-body: 'Noto Serif SC', 'Songti SC', 'PingFang SC', serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(180deg, var(--sky-top), var(--sky-mid) 42%, var(--sky-bottom));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  font-weight: 400;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

/* 顶部导航 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(248, 244, 234, 0.78);
  backdrop-filter: blur(10px);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.site-header .logo {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.site-header .logo-zh {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.site-header .logo-en {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--soft-ink);
  opacity: 0.9;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2.5vw, 24px);
  font-size: 15px;
}

.site-header nav a {
  text-decoration: none;
  opacity: 0.88;
}

.site-header button {
  padding: 4px 14px;
  border: 1px solid rgba(90, 143, 123, 0.45);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.site-header .me {
  color: var(--accent);
}

/* 首页大图 */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: calc(100vh - 56px);
  padding: clamp(48px, 12vh, 120px) 20px 40px;
  text-align: center;
  color: var(--paper);
}

.hero h1 {
  margin: 0;
  font-size: clamp(44px, 9vw, 88px);
  letter-spacing: 0.3em;
  color: var(--star);
  text-shadow: 0 0 24px rgba(255, 220, 140, 0.45);
}

.hero p {
  max-width: 36em;
  text-wrap: balance;
  margin: 16px 0 0;
  font-size: clamp(16px, 2.2vw, 20px);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.hero .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-block;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #f8fbf8;
  font-size: 17px;
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(90, 143, 123, 0.28);
}

.button.ghost {
  background: rgba(248, 244, 234, 0.7);
  border: 1px solid rgba(90, 143, 123, 0.35);
  backdrop-filter: blur(4px);
  color: var(--ink);
  box-shadow: none;
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 内容区：奶油色的纸 */
.sheet {
  max-width: 1080px;
  margin: 0 auto 48px;
  padding: clamp(20px, 4vw, 40px);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 12px 40px rgba(61, 74, 58, 0.08);
  border: 1px solid var(--line);
}

.sheet h2,
.sheet h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sheet h2 {
  font-size: 28px;
}

.sheet h3 {
  margin-top: 28px;
  font-size: 20px;
}

.sheet .plain {
  padding-left: 1.2em;
  color: var(--ink);
}

.sheet .plain li {
  margin: 0.4em 0;
}

.sheet .lead {
  margin: 0 0 20px;
  color: var(--soft-ink);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.steps div {
  padding: 16px 18px;
  border-radius: 16px;
  background: white;
}

.steps b {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
}

/* 居民卡片 */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: white;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(91, 70, 54, 0.08);
  transition: transform 0.2s;
}

.cat-card:hover {
  transform: translateY(-3px);
}

.cat-card-photo {
  aspect-ratio: 1;
  background: #fcf4de;
}

.cat-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cat-card-body {
  padding: 10px 14px 14px;
}

.cat-card-name {
  font-size: 18px;
  font-weight: 700;
}

.cat-card-owner {
  font-size: 13px;
  color: var(--soft-ink);
}

.cat-card-status {
  margin-top: 6px;
  font-size: 13px;
}

.cat-card-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #7cc47f;
  vertical-align: 1px;
}

.cat-card-status.out::before {
  background: #c9b9a6;
}

.more {
  margin-top: 20px;
  text-align: center;
}

.more a {
  color: var(--accent);
}

footer {
  padding: 28px 24px 40px;
  text-align: center;
  font-size: 13px;
  color: var(--soft-ink);
}

footer .footer-links {
  display: inline-flex;
  gap: 14px;
  margin-left: 12px;
}

footer .footer-links a {
  text-decoration: none;
  opacity: 0.85;
}

footer .footer-links a:hover {
  color: var(--accent);
}

/* 猫猫主页 */
.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.profile-head img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  background: #fcf4de;
}

.profile-head h1 {
  margin: 0;
  font-size: 32px;
}

.profile-head .sub {
  color: var(--soft-ink);
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
}

@media (max-width: 820px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.room-frame {
  width: 100%;
  border: 0;
  border-radius: 18px;
  background: var(--paper);
  aspect-ratio: 576 / 720;
}

.room-frame.owner {
  aspect-ratio: 576 / 820;
}

.room-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--soft-ink);
  text-align: center;
}

.room-static {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  aspect-ratio: 576 / 720;
  background: url('/assets/home45/room.jpg') center 21% / 100% auto no-repeat var(--paper);
}

.room-static img {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 34%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  mix-blend-mode: multiply;
}

.room-static .badge {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  white-space: nowrap;
}

.card {
  padding: 18px 20px;
  border-radius: 18px;
  background: white;
}

.card + .card {
  margin-top: 16px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
}

.facts dt {
  color: var(--soft-ink);
}

.facts dd {
  margin: 0;
}

.story p {
  margin: 0 0 10px;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  position: relative;
  padding: 0 0 10px 20px;
  border-left: 2px solid var(--line);
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline time {
  display: block;
  font-size: 13px;
  color: var(--soft-ink);
}

.candle {
  display: flex;
  align-items: center;
  gap: 14px;
}

.candle .count {
  color: var(--soft-ink);
}

.messages {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.messages li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.messages .from {
  font-weight: 600;
}

.messages time {
  margin-left: 8px;
  font-size: 12px;
  color: var(--soft-ink);
}

.message-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.message-form input {
  flex: 1;
  min-width: 0;
}

input,
textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
}

.demo-switch {
  margin: 0 0 16px;
  padding: 8px 14px;
  border-radius: 12px;
  background: #fff3d6;
  font-size: 13px;
}

.demo-switch button {
  margin-left: 6px;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: white;
  color: var(--accent);
  cursor: pointer;
}

/* 送它来猫星 */
.form {
  display: grid;
  gap: 16px;
  max-width: 640px;
}

.form label {
  display: grid;
  gap: 6px;
}

.form .hint {
  font-size: 13px;
  color: var(--soft-ink);
}

.form .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.slug-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.slug-input input {
  flex: 1;
}

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

.photos img {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  object-fit: cover;
}

.error {
  color: #c4553a;
  font-size: 13px;
}

.arriving {
  text-align: center;
  padding: 24px 0;
}

.arriving img {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
}

/* 猫星（首页和街区是同一页）：一层套一层的画（pipeline/site/register_ghibli.py），
   每层的边缘渐隐做在图片的透明通道里，这里不用 CSS 遮罩（放大缩小时很费）。 */
.world-page {
  background: #6fa8dc;
}

.world {
  position: relative;
  height: calc(100svh - 56px);
  min-height: 420px;
  overflow: hidden;
}

.world-view {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #6fa8dc;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.world-view.dragging {
  cursor: grabbing;
}

.world-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.world-view.moving .world-canvas,
.world-view.dragging .world-canvas {
  will-change: transform;
}

.world-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 外面两层：位置和大小由 world-page.js 按 town.json 摆。镜头远到看不清时隐藏，省得每帧都画。 */
.world-layer {
  position: absolute;
  max-width: none;
  pointer-events: none;
}

.world-layer.off {
  visibility: hidden;
}

/* 城镇的两层高清细节：和整张图上同一块对齐，刀口外是透明的。放大时淡入。 */
.town-detail {
  position: absolute;
  max-width: none;
  opacity: var(--detail, 1);
  pointer-events: none;
}

.town-detail.off,
.town-cats.off {
  visibility: hidden;
}

/* 小屋和地标的点击框铺在整座城镇上；镜头在飞、或者远到看不清时不能点。 */
.town-spots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.town-spots .spot {
  pointer-events: auto;
}

.world-view.moving .town-spots,
.world-view.intro .town-spots {
  display: none;
}

/* 广场上的猫：位置由 town-cats.js 摆，按落脚点前后叠放。 */
.town-cats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--detail, 1);
}

.town-cat {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity 0.8s;
}

.town-cat.shown {
  opacity: 1;
}

.town-cat-flip,
.town-cat video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.town-cat-flip.right {
  transform: scaleX(-1);
}

.town-cat video {
  opacity: 0;
}

.town-cat video.on {
  opacity: 1;
}

/* 脚下的影子，中心在落脚点（画面 50%、67.4%）。 */
.town-cat::before {
  content: '';
  position: absolute;
  left: 27%;
  top: 62%;
  width: 46%;
  height: 11%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 52, 30, 0.42), rgba(40, 52, 30, 0.18) 60%, transparent);
}

/* 说明文字：桌面在左边，手机在上面。镜头会把岛放在没被挡住的地方。 */
.world-panel {
  position: absolute;
  z-index: 2;
  left: clamp(16px, 4vw, 56px);
  top: 50%;
  width: 360px;
  padding: 24px 26px;
  border-radius: 8px;
  background: rgba(248, 244, 234, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(61, 74, 58, 0.12);
  border: 1px solid var(--line);
  transform: translateY(-50%);
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
}

.world-panel.shown {
  opacity: 1;
  pointer-events: auto;
}

/* 全景时只在顶上留一行字，整个猫星放在下面。 */
.world-panel[data-place='overview'] {
  left: 50%;
  top: 8px;
  width: auto;
  padding: 0;
  background: none;
  backdrop-filter: none;
  box-shadow: none;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}

.world-panel .place-overview h1 {
  display: inline;
  margin-right: 12px;
}

.world-panel .place-overview p {
  display: inline;
}

.world-panel .place {
  display: none;
}

.world-panel[data-place='plaza'] .place-plaza,
.world-panel[data-place='house'] .place-house,
.world-panel[data-place='overview'] .place-overview {
  display: block;
}

.world-panel h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 6vw, 72px);
  letter-spacing: 0.28em;
  color: var(--ink);
  text-shadow: none;
}

.world-panel .place-house h1,
.world-panel .place-overview h1 {
  font-size: clamp(28px, 3.4vw, 42px);
  letter-spacing: 0.15em;
}

.world-panel p {
  margin: 8px 0 20px;
  font-size: 16px;
}

.plaza-legend {
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--soft-ink);
}

.plaza-legend li {
  margin: 6px 0;
}

.plaza-legend b {
  margin-right: 8px;
  color: var(--star);
  font-weight: 600;
}

.world-panel .small {
  font-size: 13px;
  color: rgba(254, 247, 229, 0.65);
}

/* 底下的按钮：上一区、回广场、看全景、下一区 */
.world-nav {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 14px;
  display: flex;
  gap: 8px;
  max-width: calc(100% - 16px);
  transform: translateX(-50%);
}

.world-nav a,
.world-nav button {
  padding: 8px 16px;
  border: 1px solid rgba(255, 231, 168, 0.45);
  border-radius: 999px;
  background: rgba(14, 24, 66, 0.72);
  backdrop-filter: blur(6px);
  color: var(--star);
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.world-nav a:hover,
.world-nav button:hover {
  background: rgba(40, 52, 110, 0.85);
}

.world-view.intro ~ .world-nav {
  visibility: hidden;
}

@media (max-width: 860px) {
  .world-panel {
    left: 0;
    right: 0;
    top: 0;
    width: auto;
    padding: 10px 16px 14px;
    border-radius: 0;
    background: linear-gradient(rgba(12, 22, 62, 0.92) 70%, rgba(12, 22, 62, 0));
    backdrop-filter: none;
    box-shadow: none;
    transform: none;
    text-align: center;
  }

  .world-panel h1 {
    font-size: 34px;
  }

  .world-panel .place-house h1,
  .world-panel .place-overview h1 {
    font-size: 24px;
  }

  .world-panel p {
    margin: 2px 0 8px;
    font-size: 13px;
  }

  .world-panel .long,
  .plaza-legend {
    display: none;
  }

  .world-panel .button {
    padding: 8px 20px;
    font-size: 15px;
  }

  .world-nav {
    bottom: 10px;
    gap: 6px;
  }

  .world-nav a,
  .world-nav button {
    padding: 7px 11px;
    font-size: 13px;
  }
}

/* 首页是白天的画：顶栏、说明、按钮都换成半透明的奶油色和深棕色字。 */
.world-page .site-header {
  background: rgba(255, 249, 235, 0.82);
  color: var(--ink);
}

.world-page .site-header .logo,
.world-page .site-header .me {
  color: var(--ink);
}

.world-page .site-header button {
  border-color: rgba(90, 143, 123, 0.4);
  color: var(--accent);
}

.world-page .world-panel {
  background: rgba(248, 244, 234, 0.9);
  box-shadow: 0 10px 40px rgba(61, 74, 58, 0.12);
  color: var(--ink);
}

.world-page .world-panel[data-place='overview'] {
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(248, 244, 234, 0.9);
}

.world-page .world-panel h1 {
  color: var(--ink);
  text-shadow: none;
}

.world-page .plaza-legend,
.world-page .world-panel .small {
  color: var(--soft-ink);
}

.world-page .plaza-legend b {
  color: var(--accent);
}

.world-page .world-nav a,
.world-page .world-nav button {
  border-color: rgba(90, 143, 123, 0.28);
  background: rgba(248, 244, 234, 0.9);
  color: var(--ink);
}

.world-page .world-nav a:hover,
.world-page .world-nav button:hover {
  background: #fff;
}

@media (max-width: 860px) {
  .world-page .world-panel {
    background: linear-gradient(rgba(255, 249, 235, 0.92) 70%, rgba(255, 249, 235, 0));
    box-shadow: none;
  }
}

/* 画上的可点区域：平时看不见，停上去亮起来。 */
.spot {
  position: absolute;
  z-index: 1;
  border-radius: 40%;
  transition: background 0.25s, box-shadow 0.25s;
}

.spot:hover,
.spot:focus-visible,
.spot.flash {
  background: radial-gradient(closest-side, rgba(255, 236, 170, 0.32), transparent);
  box-shadow: 0 0 40px 6px rgba(255, 225, 140, 0.25);
  outline: none;
}

.spot.flash {
  animation: flash 1.2s 3;
}

@keyframes flash {
  50% {
    background: radial-gradient(closest-side, rgba(255, 236, 170, 0.6), transparent);
  }
}

.spot-card {
  position: fixed;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 16px);
  padding: 8px 14px 8px 8px;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.spot-card::after {
  content: '';
  position: absolute;
  left: var(--arrow, 50%);
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--paper);
  transform: translateX(-50%) rotate(45deg);
}

.spot-card.below::after {
  top: -6px;
  bottom: auto;
}

.spot-card:not(:has(img)) {
  padding-left: 14px;
}

.spot-card img,
.spot-sheet img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #fcf4de;
}

.spot-card b,
.spot-sheet b {
  display: block;
  font-size: 16px;
}

.spot-card small,
.spot-sheet small {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: var(--soft-ink);
}

.spot-card small:empty,
.spot-sheet small:empty {
  display: none;
}

/* 手机上点了以后从底下弹出来 */
.spot-sheet {
  position: fixed;
  z-index: 20;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px 14px;
  padding: 18px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.35);
  animation: sheet-in 0.3s both;
}

.spot-sheet:not(:has(img)) {
  grid-template-columns: 1fr;
}

.spot-sheet img {
  width: 64px;
  height: 64px;
}

.spot-sheet .button {
  grid-column: 1 / -1;
  text-align: center;
}

.spot-sheet .close {
  position: absolute;
  right: 10px;
  top: 6px;
  border: 0;
  background: none;
  font-size: 22px;
  color: var(--soft-ink);
  cursor: pointer;
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

/* 街区里的屋 */
.spot.mine {
  box-shadow: 0 0 0 3px rgba(255, 220, 140, 0.8), 0 0 30px 6px rgba(255, 220, 140, 0.4);
}

.spot.empty {
  background: rgba(14, 27, 75, 0.35);
}

.street-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--soft-ink);
}

.street-links a {
  padding: 2px 10px;
  border-radius: 999px;
  background: white;
  color: var(--ink);
  text-decoration: none;
}
