* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0; padding: 0; background-color: #2c2520;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  height: 100vh; font-family: "游明朝", "Yu Mincho", "Hiragino Mincho ProN", serif;
  overflow: hidden; user-select: text;
}

#toolbar { margin-bottom: 12px; display: flex; gap: 6px; z-index: 50; flex-wrap: wrap; justify-content: center; }
.tool-btn {
  background: #4a3f35; color: #f7f3e8; border: 1px solid #6e5d4f;
  padding: 6px 12px; border-radius: 20px; font-family: sans-serif; font-size: 12px; cursor: pointer;
}
.tool-btn:hover { background: #635447; }
.tool-btn.active { background: #a83232; border-color: #ff7b7b; }

#book-container {
  position: relative; width: 85vw; max-width: 920px; height: 82vh;
  background-color: #f7f3e8;
  background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
  background-size: 20px 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.7), inset 0 0 40px rgba(180, 160, 130, 0.25);
  border-radius: 4px; display: flex; overflow: hidden; transition: background-color 0.5s;
}

#lamp-overlay {
  display: none; position: absolute; inset: 0; pointer-events: none; z-index: 30;
  background: radial-gradient(circle 220px at 50% 50%, transparent 10%, rgba(15, 12, 8, 0.88) 85%);
}

#edge-left, #edge-right {
  height: 100%; transition: width 0.3s;
  background: repeating-linear-gradient(90deg, #e6dec8, #e6dec8 1px, #d1c7ae 1px, #d1c7ae 2px);
}
#edge-left { border-right: 1px solid #bfb395; width: 4px; }
#edge-right { border-left: 1px solid #bfb395; width: 24px; }

#page-viewport { flex: 1; margin: 40px 50px; overflow: hidden; position: relative; }
#book-content {
  writing-mode: vertical-rl; text-orientation: upright;
  height: 100%; font-size: 19px; line-height: 2.1; letter-spacing: 0.08em;
  color: #2b2b2b; transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}
ruby rt { font-size: 0.5em; color: #555; }

.red-pencil {
  border-right: 3px solid #d9381e !important;
  background-color: rgba(230, 80, 60, 0.18) !important;
  padding-right: 2px; cursor: pointer;
}
.sticky-note-mark {
  background-color: #fff176 !important;
  border-bottom: 2px solid #fbc02d !important;
  cursor: pointer; position: relative;
}
.sticky-note-mark::after { content: "📌"; font-size: 11px; vertical-align: super; }

.nav-zone { position: absolute; top: 0; bottom: 0; width: 12%; cursor: pointer; z-index: 10; }
#prev-zone { right: 0; }
#next-zone { left: 0; }
.nav-zone:hover { background: rgba(0,0,0,0.03); }

#bookmark-ribbon {
  position: absolute; top: -10px; left: 80px; width: 16px; height: 65px;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%);
  cursor: pointer; z-index: 25; transition: all 0.2s;
}
#bookmark-ribbon:hover { height: 80px; }
.bm-red { background-color: #a83232; }
.bm-leather { background-color: #5d3a1a; border-left: 2px dashed #d4a373; }
.bm-flower { background: linear-gradient(180deg, #e8f5e9, #a5d6a7); border: 1px solid #81c784; }
.bm-gold { background: linear-gradient(135deg, #d4af37, #f9e596, #aa7c11); }

#selection-menu {
  position: absolute; bottom: 35px; left: 35px; width: 320px;
  background: #fffdf0; border-left: 6px solid #e6b422;
  box-shadow: 3px 5px 15px rgba(0,0,0,0.3); padding: 15px;
  font-family: sans-serif; font-size: 14px; color: #333; z-index: 40;
}
#dict-word { font-size: 15px; color: #a83232; }
#dict-desc { margin: 8px 0; line-height: 1.5; font-size: 13px; }
.menu-btns { display: flex; gap: 6px; margin-top: 10px; }
.btn-red { background: #a83232; color: white; border: none; padding: 5px 8px; border-radius: 3px; cursor: pointer; font-size: 12px; }
.btn-yellow { background: #f5b014; color: #222; border: none; padding: 5px 8px; border-radius: 3px; cursor: pointer; font-size: 12px; font-weight: bold; }

#status-bar { position: absolute; bottom: 12px; right: 50px; font-size: 12px; color: #8c8270; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; justify-content: center; align-items: center; z-index: 999; font-family: sans-serif;
}
.modal-box {
  background: #f5efe6; width: 85vw; max-width: 800px; max-height: 85vh;
  border-radius: 8px; padding: 20px; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #d4c8b4; padding-bottom: 10px; }
.modal-header h2 { margin: 0; font-family: serif; color: #3b2f2f; }
.close-btn { background: #4a3f35; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }

#character-memo-area {
  width: 100%; padding: 12px; font-family: serif; font-size: 15px; line-height: 1.6;
  background: #fffdf9; border: 1px solid #bfb395; border-radius: 4px; resize: vertical;
}

.search-bar { display: flex; gap: 10px; margin: 10px 0; }
.search-bar input { flex: 1; padding: 8px; border: 1px solid #bfb395; border-radius: 4px; }
.file-btn { background: #2e6b4e; color: white; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: 200px; overflow-y: auto; padding: 5px; }
.catalog-item { background: white; border: 1px solid #dcd0bc; padding: 10px; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; }
.dl-btn { background: #a83232; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }

.bookshelf-row { display: flex; gap: 18px; padding: 20px; background: #4a3525; border-bottom: 12px solid #2e1f14; border-radius: 4px; overflow-x: auto; min-height: 170px; }
.bunko-cover {
  width: 110px; height: 160px; background: #fdfbf7; border: 1px solid #ccc; box-shadow: 3px 4px 8px rgba(0,0,0,0.5);
  padding: 10px 8px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: transform 0.2s; flex-shrink: 0; font-family: serif; position: relative;
}
.bunko-cover:hover { transform: translateY(-6px); }
.bunko-spine-line { position: absolute; left: 6px; top: 0; bottom: 0; width: 1px; background: #ddd; }
.bunko-title { writing-mode: vertical-rl; font-weight: bold; font-size: 14px; color: #222; margin: 0 auto; height: 100px; }
.bunko-author { font-size: 11px; color: #666; text-align: center; border-top: 1px solid #a83232; padding-top: 4px; }

.obi-card {
  width: 240px; height: 340px; margin: 15px auto; background: #fdfbf7; border: 1px solid #ccc; box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 25px 15px; font-family: serif;
}
.obi-title { writing-mode: vertical-rl; font-size: 22px; font-weight: bold; margin: 0 auto; height: 160px; }
.obi-author { text-align: center; font-size: 14px; color: #555; }
.obi-band { background: #a83232; color: #fffdf0; padding: 12px; margin: 0 -15px -25px -15px; text-align: center; border-top: 3px solid #e6b422; }
.obi-band p { margin: 0 0 5px 0; font-weight: bold; font-size: 14px; }
