/* ========== yingyu-room.css ==========
   詠諭的房間 page — room scene, bookshelf, desk, bed,
   saved chats panel, bookshelf panel,
   story mode, day/night photo mode
   ============================== */

/* 詠諭的房間 */
#yingyu-room-page {
  display: none; position: fixed; inset: 0; background: var(--bg); z-index: 200; flex-direction: column;
}
#yingyu-room-page.active { display: flex; }
#yingyu-room-header {
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#yingyu-room-back-btn {
  width: 34px; height: 34px; border-radius: 50%; background: none; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#yingyu-room-back-btn svg { width: 16px; height: 16px; stroke: var(--text-muted); }
#yingyu-room-scene { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#yingyu-room-wall {
  flex: 1; background: linear-gradient(180deg, #d8cfc8 0%, #cec4bc 100%);
  display: flex; align-items: flex-end; justify-content: space-around;
  padding: 20px 20px 0; position: relative;
}
#yingyu-room-window {
  width: 90px; height: 80px; background: #c8dce8;
  border: 3px solid #a0b0bc; display: grid; grid-template-columns: 1fr 1fr;
  gap: 2px; padding: 2px; margin-bottom: 0; flex-shrink: 0; align-self: flex-start; margin-top: 10px;
}
#yingyu-room-window .window-pane { background: rgba(190,220,240,0.6); }
#yingyu-bookshelf {
  width: 110px; background: #b89468;
  border: 2px solid #907050; border-radius: 4px 4px 0 0;
  display: flex; flex-direction: column; padding: 6px 4px 0; gap: 0;
  cursor: pointer; position: relative; height: 120px; justify-content: flex-start;
}
#yingyu-bookshelf:hover { filter: brightness(1.06); }
.shelf-row { display: flex; align-items: flex-end; gap: 3px; padding: 0 2px 2px; flex: 1; }
.shelf-divider { height: 4px; background: #785030; border-radius: 1px; margin: 0 -4px; }
.book { border-radius: 1px 2px 2px 1px; flex: 1; }
.book.b1 { background: #c87060; height: 40px; }
.book.b2 { background: #6090c8; height: 34px; }
.book.b3 { background: #60b060; height: 38px; }
.book.b4 { background: #c8a848; height: 32px; }
.book.b5 { background: #9060a8; height: 36px; }
.book.b6 { background: #50b8b8; height: 30px; }
.book.b7 { background: #c87848; height: 35px; }
#shelf-label { font-size: 9px; color: #504030; text-align: center; padding: 2px 0 3px; }
#yingyu-room-baseboard { height: 10px; background: #b8a898; flex-shrink: 0; }
#yingyu-room-floor {
  height: 140px; flex-shrink: 0;
  background: repeating-linear-gradient(90deg, #b89468 0px, #b89468 56px, #a8845a 56px, #a8845a 58px);
  border-top: 2px solid #907450;
  display: flex; align-items: flex-end; padding: 0 20px 0; gap: 16px;
}
#yingyu-room-bed { display: flex; flex-direction: column; align-items: flex-start; flex-shrink: 0; }
#yingyu-bed-headboard { width: 120px; height: 36px; background: linear-gradient(180deg, #8b6445, #7a5538); border-radius: 6px 6px 0 0; box-shadow: 0 -2px 8px rgba(0,0,0,0.15); }
#yingyu-bed-body { width: 120px; height: 56px; background: #e8e0d8; border: 2px solid #c8b8a8; display: flex; flex-direction: column; overflow: hidden; }
#yingyu-bed-pillow { height: 20px; background: #f0ece8; border-bottom: 1px solid #d8ccc0; }
#yingyu-bed-blanket { flex: 1; background: linear-gradient(135deg, #8090a8, #6878a0); }

/* 長按選單 */
#msg-ctx-menu {
  display: none; position: fixed; z-index: 300;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18); overflow: hidden; min-width: 160px;
}
#msg-ctx-menu.active { display: block; }
.ctx-menu-item {
  padding: 13px 18px; font-size: 14px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.ctx-menu-item:hover { background: var(--hover); }
.ctx-menu-item + .ctx-menu-item { border-top: 1px solid var(--border); }
/* 存入 toast */
#save-toast {
  display: none; position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #fff; padding: 8px 18px; border-radius: 20px;
  font-size: 13px; z-index: 400; white-space: nowrap;
}
#save-toast.show { display: block; }

/* 桌子 */
#yingyu-desk {
  width: 74px; align-self: flex-end; cursor: pointer; transition: filter 0.15s; flex-shrink: 0;
}
#yingyu-desk:hover { filter: brightness(1.08); }
#yingyu-desk-top {
  width: 74px; height: 8px; background: linear-gradient(180deg, #9a7050, #7a5534); border-radius: 3px 3px 0 0;
}
#yingyu-desk-legs {
  width: 74px; height: 52px; background: linear-gradient(180deg, #8a6040, #6e4828);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.desk-drawer {
  width: 56px; height: 16px; background: linear-gradient(180deg, #7a5534, #6a4524); border-radius: 2px;
  border: 1px solid #5a3818; display: flex; align-items: center; justify-content: center;
}
.desk-drawer-handle { width: 16px; height: 3px; background: #c8a878; border-radius: 2px; }
#desk-label { font-size: 9px; color: #504030; text-align: center; margin-top: 3px; }

/* 儲存對話面板 */
#saved-chats-panel {
  display: none; position: absolute; inset: 0; background: var(--bg); z-index: 10; flex-direction: column;
}
#saved-chats-panel.active { display: flex; }
#saved-chats-header {
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#saved-chats-header span { flex: 1; font-size: 15px; font-weight: 600; }
#saved-chats-back-btn {
  width: 34px; height: 34px; border-radius: 50%; background: none; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#saved-chats-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.saved-chat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; cursor: pointer; transition: background 0.1s;
}
.saved-chat-card:hover { background: var(--hover); }
.saved-chat-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.saved-chat-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.saved-chat-card-preview { font-size: 12px; color: var(--text-muted); margin-top: 4px; opacity: 0.8; }
.saved-chat-del {
  float: right; background: none; border: none; cursor: pointer; font-size: 15px;
  color: var(--text-muted); padding: 2px 4px; margin-left: 8px;
}
/* 對話詳情 */
#saved-chat-detail {
  display: none; position: absolute; inset: 0; background: var(--bg); z-index: 20; flex-direction: column;
}
#saved-chat-detail.active { display: flex; }
#saved-chat-detail-header {
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#saved-chat-detail-back {
  width: 34px; height: 34px; border-radius: 50%; background: none; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#saved-chat-detail-title {
  flex: 1; border: none; background: none; font-size: 15px; font-weight: 600;
  color: var(--text); font-family: inherit; outline: none;
}
#saved-chat-detail-save {
  font-size: 12px; padding: 4px 12px; border-radius: 8px; border: none;
  background: var(--send-bg); color: #fff; cursor: pointer;
}
#saved-chat-detail-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.sc-msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; }
.sc-msg.user { align-self: flex-end; background: var(--send-bg); color: #fff; border-bottom-right-radius: 4px; }
.sc-msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

/* 儲存對話 modal */
#save-chat-modal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200;
  align-items: center; justify-content: center;
}
#save-chat-modal.active { display: flex; }
#save-chat-modal-box {
  background: var(--bg); border-radius: 16px; padding: 24px; width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
#save-chat-modal-box h3 { margin: 0 0 16px; font-size: 16px; }
#save-chat-title-input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px;
  color: var(--text); font-family: inherit; outline: none; margin-bottom: 16px;
}
#save-chat-modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
#save-chat-cancel { background: none; border: 1px solid var(--border); padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 13px; }
#save-chat-confirm { background: var(--send-bg); color: #fff; border: none; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 13px; }

/* 書單面板 */
#bookshelf-panel {
  display: none; position: absolute; inset: 0; background: var(--bg); z-index: 10; flex-direction: column;
}
#bookshelf-panel.active { display: flex; }
#bookshelf-panel-header {
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#bookshelf-panel-header span { flex: 1; font-size: 15px; font-weight: 600; }
#bookshelf-back-btn, #bookshelf-add-btn {
  width: 34px; height: 34px; border-radius: 50%; background: none; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#bookshelf-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.book-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.book-card-spine { width: 6px; border-radius: 3px; align-self: stretch; flex-shrink: 0; }
.book-card-info { flex: 1; }
.book-card-title { font-size: 14px; font-weight: 600; }
.book-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.book-card-play {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--send-bg); color: #fff; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
/* 書本詳情 */
#book-detail-panel {
  display: none; position: absolute; inset: 0; background: var(--bg); z-index: 20; flex-direction: column;
}
#book-detail-panel.active { display: flex; }
#book-detail-header {
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#book-detail-back {
  width: 34px; height: 34px; border-radius: 50%; background: none; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#book-detail-back svg { width: 16px; height: 16px; stroke: var(--text-muted); }
#book-detail-body {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
#book-content-input { flex: 1; min-height: 0; }
#book-audio-section {
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
#book-gen-audio-btn {
  padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: none; color: var(--text); font-size: 13px; cursor: pointer;
}


/* ========== Story Mode Panel ========== */
/* ========== Story Mode Panel ========== */
#story-mode-panel {
flex-direction: column;
align-items: center;
gap: 12px;
background: rgba(0,0,0,0.45);
border-radius: 18px;
padding: 18px 20px;
margin: 0 20px 12px;
backdrop-filter: blur(8px);
}
.story-panel-title {
color: rgba(255,255,255,0.85);
font-size: 14px;
letter-spacing: 0.5px;
}
.story-dur-row {
display: flex;
gap: 10px;
justify-content: center;
}
.story-dur-btn {
background: rgba(255,255,255,0.18);
color: #fff;
border: none;
border-radius: 20px;
padding: 8px 18px;
font-size: 14px;
cursor: pointer;
transition: background 0.15s;
}
.story-dur-btn:hover, .story-dur-btn:active {
background: rgba(255,255,255,0.35);
}
#story-mute-only-btn {
background: transparent;
color: rgba(255,255,255,0.5);
border: 1px solid rgba(255,255,255,0.25);
border-radius: 20px;
padding: 6px 16px;
font-size: 13px;
cursor: pointer;
}

/* ========== Room Day/Night Photo Mode ========== */
#yingyu-room-page.room-night { background: #1a1210; }
#yingyu-room-page.room-morning { background: #f0e8d8; }
#yingyu-room-page.room-morning #yingyu-room-header,
#yingyu-room-page.room-night #yingyu-room-header {
position: absolute;
top: 0; left: 0; right: 0;
z-index: 20;
background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
color: #fff;
border-bottom: none;
pointer-events: all;
}
#yingyu-room-page.room-morning #yingyu-room-header button,
#yingyu-room-page.room-night #yingyu-room-header button { color: #fff; }
#yingyu-room-page.room-morning #yingyu-room-header span,
#yingyu-room-page.room-night #yingyu-room-header span { color: #fff; }

#yingyu-room-page.room-morning #yingyu-room-scene,
#yingyu-room-page.room-night #yingyu-room-scene {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background-size: cover;
background-position: center top;
background-repeat: no-repeat;
}
#yingyu-room-page.room-morning #yingyu-room-scene {
background-image: url('/images/room_morning.jpg');
}
#yingyu-room-page.room-night #yingyu-room-scene {
background-image: url('/images/room_night.jpg');
}

/* hide CSS-drawn elements */
#yingyu-room-page.room-morning #yingyu-room-wall,
#yingyu-room-page.room-morning #yingyu-room-baseboard,
#yingyu-room-page.room-morning #yingyu-room-floor,
#yingyu-room-page.room-night #yingyu-room-wall,
#yingyu-room-page.room-night #yingyu-room-baseboard,
#yingyu-room-page.room-night #yingyu-room-floor,
#yingyu-room-page.room-morning #yingyu-bookshelf,
#yingyu-room-page.room-morning #yingyu-desk,
#yingyu-room-page.room-night #yingyu-bookshelf,
#yingyu-room-page.room-night #yingyu-desk { display: none; }

/* photo labels */
.room-photo-label {
display: none;
position: absolute;
cursor: pointer;
z-index: 5;
font-family: 'Georgia', 'Noto Serif TC', serif;
font-size: 13px;
color: rgba(255,255,255,0.75);
text-shadow: 0 1px 6px rgba(0,0,0,0.7);
letter-spacing: 2px;
padding: 6px 12px;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 20px;
background: rgba(0,0,0,0.18);
backdrop-filter: blur(4px);
transition: background 0.2s;
}
.room-photo-label:active { background: rgba(255,255,255,0.2); }
#yingyu-room-page.room-morning .room-photo-label,
#yingyu-room-page.room-night .room-photo-label { display: block; }

#room-label-bookshelf {
top: 40%;
left: 11%;
}
#room-label-desk {
top: 76%;
left: 5%;
}

/* bottom action bar */
#room-photo-bar {
display: none;
position: absolute;
bottom: 0; left: 0; right: 0;
padding: 12px 16px;
background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 100%);
gap: 10px;
justify-content: center;
z-index: 10;
}
#yingyu-room-page.room-morning #room-photo-bar,
#yingyu-room-page.room-night #room-photo-bar { display: flex; }

#room-photo-bar button {
background: rgba(255,255,255,0.18);
backdrop-filter: blur(6px);
color: #fff;
border: 1px solid rgba(255,255,255,0.25);
border-radius: 20px;
padding: 10px 28px;
font-size: 14px;
font-family: 'Georgia', 'Noto Serif TC', serif;
letter-spacing: 2px;
cursor: pointer;
}
#room-photo-bar button:active { background: rgba(255,255,255,0.35); }

#room-theme-toggle-btn {
margin-left: auto;
background: none;
border: none;
font-size: 20px;
cursor: pointer;
padding: 4px 6px;
border-radius: 8px;
line-height: 1;
}
#room-theme-toggle-btn:active { opacity: 0.6; }

/* photo mode: active sub-panels must sit above the absolute room header (z-index:20) */
#yingyu-room-page.room-morning #bookshelf-panel.active,
#yingyu-room-page.room-night  #bookshelf-panel.active,
#yingyu-room-page.room-morning #saved-chats-panel.active,
#yingyu-room-page.room-night  #saved-chats-panel.active {
z-index: 30;
}
