:root {
  --theme: #00a4fe;
  --light: #CFEBFF;
  --dark: #0069B8;
  --ink: #0B1B2B;
  --wall: #F9F8F4;
  --wood: #E5D3B3;
  --floor: #D9CBB3;
  --grey: #E6E8EA;
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background-color: var(--wall);
  color: var(--ink);
  line-height: 1.6;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* Typography */
h1, h2, h3, h4 { font-weight: 800; line-height: 1.2; }
.plate-font { font-family: var(--font-mono); font-weight: bold; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--wall);
  border-bottom: 2px solid var(--ink);
  padding: 0 24px;
  display: flex; justify-content: space-between; align-items: center;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; }
.brand img { height: 32px; width: auto; }
.header-nav { display: none; gap: 8px; overflow-x: auto; }
.nav-plate {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--ink);
  border-radius: 4px; font-size: 14px; font-weight: bold;
  background: var(--wall); white-space: nowrap;
  transition: background 0.2s;
}
.nav-plate:hover, .nav-plate.active { background: var(--theme); color: var(--ink); }
.header-actions { display: flex; align-items: center; gap: 16px; position: relative; }
.door-plate {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--theme); color: var(--ink);
  padding: 0 20px; height: 44px; border-radius: 6px;
  border: 2px solid var(--ink); font-weight: 800; font-size: 16px;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.1s;
}
.door-plate:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.door-plate svg { width: 18px; height: 18px; fill: currentColor; }
.door-plate:hover .qr-card { display: block; }
.qr-card {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 12px;
  background: #fff; border: 2px solid var(--ink); padding: 12px; border-radius: 8px;
  box-shadow: 4px 4px 0 rgba(11,27,43,0.1); z-index: 101;
}
.qr-card p { font-size: 12px; text-align: center; margin-top: 8px; font-weight: bold; }
.menu-toggle { display: flex; flex-direction: column; gap: 4px; width: 24px; height: 24px; justify-content: center; }
.menu-toggle span { display: block; width: 100%; height: 2px; background: var(--ink); }

/* Mobile Drawer */
.mobile-drawer {
  position: fixed; top: 64px; left: 0; width: 100%; height: calc(100vh - 64px);
  background: var(--wall); z-index: 99; padding: 24px;
  transform: translateX(-100%); transition: transform 0.3s ease;
  overflow-y: auto;
}
.mobile-drawer.open { transform: translateX(0); }
.drawer-list { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.drawer-list a { font-size: 18px; font-weight: bold; display: block; padding: 12px; border-bottom: 1px solid var(--grey); }

/* Main & Sections */
main { padding-bottom: 80px; }
section { padding: 60px 24px; border-bottom: 1px solid var(--grey); position: relative; }
section:nth-child(even) { background: #fff; }
.container { max-width: 1200px; margin: 0 auto; }
.room-title { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.floor-tag {
  font-family: var(--font-mono); font-size: 14px; font-weight: bold;
  background: var(--ink); color: #fff; padding: 4px 8px; border-radius: 4px;
}
.room-title h2 { font-size: 32px; }
.room-title p { color: #555; width: 100%; max-width: 600px; margin-top: 8px; }

/* Hero */
.hero { display: flex; flex-direction: column; gap: 32px; padding-top: 40px; background: var(--wall); }
.hero-text { flex: 1; }
.hero-text h1 { font-size: 40px; margin-bottom: 16px; letter-spacing: -1px; }
.hero-text .sub { font-size: 18px; margin-bottom: 24px; color: #333; }
.download-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.btn-group { display: flex; gap: 12px; }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border: 2px solid var(--ink); border-radius: 6px;
  font-weight: bold; font-size: 14px; background: transparent;
}
.trust-badge {
  display: flex; gap: 16px; font-size: 14px; font-weight: bold;
  background: var(--light); padding: 12px 16px; border-radius: 8px; border: 2px solid var(--ink);
}
.hero-shelves { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.hero-books { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.hero-books .book-card:nth-child(n+5) { display: none; }
.ranking-wall { background: var(--wood); padding: 16px; border-radius: 8px; border: 2px solid var(--ink); }
.ranking-wall h3 { font-size: 16px; margin-bottom: 12px; border-bottom: 1px solid var(--ink); padding-bottom: 8px; }
.rank-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.rank-num { font-family: var(--font-mono); font-weight: bold; width: 20px; }
.rank-cover { width: 40px; aspect-ratio: 3/4; object-fit: cover; border-radius: 2px; border: 1px solid var(--ink); }
.rank-info { display: flex; flex-direction: column; flex: 1; }
.rank-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-source { font-size: 12px; color: var(--dark); }

/* Book Cards */
.book-card { display: flex; flex-direction: column; position: relative; cursor: pointer; }
.book-cover { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 4px 4px 2px 2px; border: 1px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); transition: transform 0.2s; }
.book-card:hover .book-cover { transform: translateY(-4px); }
.book-spine { background: var(--ink); color: #fff; font-size: 11px; padding: 4px 6px; border-radius: 2px; margin-top: 4px; display: flex; justify-content: space-between; }
.book-meta { font-size: 12px; margin-top: 4px; display: flex; justify-content: space-between; color: #555; }
.book-hook { font-size: 12px; margin-top: 4px; color: var(--dark); font-weight: bold; display: none; }
.book-card:hover .book-hook { display: block; }

/* Rooms */
/* 2F 日漫 */
.room-2f { background: var(--wall); }
.tatami-bg { background-color: #E8E0D5; background-image: repeating-linear-gradient(0deg, transparent, transparent 20px, rgba(0,0,0,0.03) 20px, rgba(0,0,0,0.03) 21px), repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(0,0,0,0.03) 20px, rgba(0,0,0,0.03) 21px); padding: 24px; border-radius: 8px; border: 2px solid var(--ink); }
.shelf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.shoji-door { margin-top: 24px; background: var(--wood); height: 120px; border: 2px solid var(--ink); border-radius: 4px; position: relative; overflow: hidden; }
.shoji-door::after { content: "拉开障子门 →"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-weight: bold; }
.hidden-books { display: none; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 16px; }
.hidden-books.open { display: grid; }

/* 3F 韩漫 */
.room-3f { background: #fff; }
.scroll-columns { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.scroll-col { display: flex; flex-direction: column; gap: 16px; min-width: 120px; }
.scroll-col .book-card { width: 120px; }
.window-vert { background: var(--light); height: 200px; border: 4px solid var(--ink); display: flex; align-items: center; justify-content: center; margin-top: 24px; cursor: pointer; border-radius: 4px; }
.window-content { display: none; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 16px; background: var(--theme); border: 2px solid var(--ink); }
.window-content.open { display: grid; }

/* 4F 国漫 */
.room-4f { background: #F4EEE5; }
.scroll-long { display: flex; gap: 16px; overflow-x: auto; padding: 24px 0; scroll-behavior: smooth; border-top: 4px solid var(--wood); border-bottom: 4px solid var(--wood); }
.scroll-long::-webkit-scrollbar { height: 8px; }
.scroll-long::-webkit-scrollbar-thumb { background: var(--ink); border-radius: 4px; }
.scroll-long .book-card { min-width: 140px; }

/* 阁楼 */
.attic { background: #2A3038; color: #E6E8EA; transition: background 0.3s, color 0.3s; }
.attic.lit { background: var(--wall); color: var(--ink); }
.attic .room-title h2 { color: inherit; }
.attic .floor-tag { background: #E6E8EA; color: #2A3038; }
.attic.lit .floor-tag { background: var(--ink); color: #fff; }
.light-pull { width: 40px; height: 60px; background: transparent; border-right: 2px solid currentColor; margin-bottom: 24px; position: relative; cursor: pointer; }
.light-pull::after { content: ""; position: absolute; bottom: 0; right: -6px; width: 10px; height: 10px; background: currentColor; border-radius: 50%; }
.attic-books { display: none; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 24px; }
.attic-books.show { display: grid; }

/* 更新 */
.door-gap { background: var(--wood); padding: 24px; border-radius: 8px; border: 2px solid var(--ink); position: relative; }
.update-list { display: flex; gap: 16px; overflow-x: auto; padding: 16px 0; }
.update-list .book-card { min-width: 120px; }
.badge-new { background: var(--theme); color: var(--ink); font-size: 12px; font-weight: bold; padding: 2px 6px; border-radius: 2px; display: inline-block; margin-top: 4px; }

/* 书房 */
.study { background: #fff; }
.shelf-3-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 32px; }
.shelf-col { border-bottom: 4px solid var(--ink); padding-bottom: 16px; min-height: 200px; }
.shelf-col h4 { font-size: 14px; margin-bottom: 12px; border-bottom: 1px solid var(--grey); padding-bottom: 4px; }
.shelf-col .book-card { width: 60px; display: inline-block; margin: 0 8px 8px 0; }
.pending-books { display: flex; gap: 12px; overflow-x: auto; padding: 16px 0; }
.pending-books .book-card { min-width: 80px; }
.desk-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 32px; }
.desk-item { background: var(--light); padding: 16px; border: 2px solid var(--ink); border-radius: 8px; font-weight: bold; text-align: center; }

/* 后院 */
.backyard { background: #EAF4EA; }
.wall-comments { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 32px; }
.comment { background: #fff; padding: 12px; border: 2px solid var(--ink); border-radius: 8px; box-shadow: 2px 2px 0 var(--ink); font-size: 14px; }
.benches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.bench { background: var(--wood); padding: 16px; border: 2px solid var(--ink); border-radius: 4px; }
.topic-card { background: #fff; padding: 16px; border: 2px solid var(--ink); border-radius: 4px; text-align: center; aspect-ratio: 3/4; display: flex; flex-direction: column; justify-content: center; }

/* 信箱 */
.mailbox { background: var(--wall); }
.mail-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.letter { background: #fff; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; }
.letter summary { padding: 16px; font-weight: bold; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.letter summary::-webkit-details-marker { display: none; }
.letter-content { padding: 16px; border-top: 1px dashed var(--grey); font-size: 14px; }

/* 屋顶 */
.roof { background: var(--theme); color: var(--ink); border: none; padding: 80px 24px; text-align: center; }
.roof-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 48px; }
.roof-tiles img { width: 60px; aspect-ratio: 3/4; object-fit: cover; border: 1px solid rgba(11,27,43,0.2); border-radius: 2px; }
.roof h2 { font-size: 36px; margin-bottom: 24px; font-weight: 900; }
.roof .door-plate { background: #fff; color: var(--ink); height: 56px; font-size: 20px; padding: 0 32px; margin: 0 auto; }
.roof-qr { margin-top: 32px; background: #fff; padding: 16px; border-radius: 8px; display: inline-block; border: 2px solid var(--ink); }

/* Footer */
.site-footer { background: #0B1B2B; color: #9CA3AF; padding: 48px 24px 24px; font-size: 12px; }
.footer-content { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.footer-top { display: flex; flex-direction: column; gap: 16px; border-bottom: 1px solid #374151; padding-bottom: 24px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 12px; }
.footer-links a { color: #D1D5DB; }
.footer-links a:hover { text-decoration: underline; }
.footer-bottom { display: flex; flex-direction: column; gap: 12px; }
.site-about { margin-top: 12px; }
.site-about summary { cursor: pointer; list-style: none; display: inline-block; padding: 4px 0; color: #D1D5DB; }
.site-about summary::-webkit-details-marker { display: none; }
.site-about .about-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; color: #9CA3AF; }

/* Responsive */
@media (min-width: 768px) {
  .header-nav { display: flex; }
  .menu-toggle { display: none; }
  .hero { flex-direction: row; }
  .hero-text { width: 40%; }
  .hero-shelves { width: 60%; }
  .hero-books { grid-template-columns: repeat(4, 1fr); }
  .shelf { grid-template-columns: repeat(4, 1fr); }
  .scroll-columns { gap: 24px; }
  .scroll-long .book-card { min-width: 160px; }
  .attic-books { grid-template-columns: repeat(4, 1fr); }
  .shelf-3-col { grid-template-columns: repeat(3, 1fr); }
  .wall-comments { grid-template-columns: repeat(4, 1fr); }
  .benches { grid-template-columns: repeat(3, 1fr); }
  .mail-grid { grid-template-columns: repeat(2, 1fr); }
  .roof-tiles img { width: 80px; }
}
@media (min-width: 1024px) {
  .hero-text h1 { font-size: 48px; }
  .hero-books { grid-template-columns: repeat(4, 1fr); }
  .scroll-columns { gap: 32px; }
  .scroll-long .book-card { min-width: 180px; }
  .attic-books { grid-template-columns: repeat(6, 1fr); }
  .mail-grid { grid-template-columns: repeat(3, 1fr); }
  .roof-tiles img { width: 100px; }
}

/* Elevator */
.elevator { display: none; position: fixed; right: 24px; top: 50%; transform: translateY(-50%); width: 32px; height: 200px; background: #fff; border: 2px solid var(--ink); border-radius: 8px; z-index: 90; }
.elevator-track { position: absolute; top: 8px; bottom: 8px; left: 50%; width: 2px; background: var(--grey); transform: translateX(-50%); }
.elevator-car { position: absolute; left: 50%; transform: translateX(-50%); width: 20px; height: 24px; background: var(--theme); border: 2px solid var(--ink); border-radius: 2px; transition: bottom 0.2s; bottom: 8px; }
@media (min-width: 1024px) {
  .elevator { display: block; }
}
/* Mobile Progress */
.mobile-progress { display: block; position: fixed; top: 64px; left: 0; height: 3px; background: var(--theme); z-index: 101; width: 0%; transition: width 0.1s; }
.mobile-download-bar { display: flex; position: fixed; bottom: 0; left: 0; width: 100%; background: #fff; border-top: 2px solid var(--ink); padding: 12px; z-index: 100; justify-content: center; }
@media (min-width: 768px) {
  .mobile-progress, .mobile-download-bar { display: none; }
}