/* ========== room.css ==========
   知臨的房間 (My Room) — room scene, bed, desk, lamp, art,
   diary panel, photos panel, room-page tabs, lock overlay, lightbox, add modal
   ============================== */

/* My Room Scene */
#my-room-scene { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#my-room-wall {
  flex: 1; background: linear-gradient(180deg, #d8cfc8 0%, #cec4bc 100%);
  display: flex; align-items: flex-start; position: relative; padding: 20px 16px 0; gap: 12px;
}
#my-room-baseboard { height: 10px; background: #b8a898; flex-shrink: 0; }
#my-room-floor {
  height: 160px; 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 12px 0; gap: 16px; position: relative;
}

/* Photo frames on wall */
#my-room-photos-area {
  display: flex; flex-direction: column; gap: 8px; cursor: pointer; padding-top: 8px;
}
#my-room-photos-area:hover .room-frame { box-shadow: 2px 3px 10px rgba(0,0,0,0.2); }
.room-frame {
  width: 54px; height: 40px; border: 3px solid #b0988a; border-radius: 2px;
  background: #e8ddd4; box-shadow: 1px 2px 6px rgba(0,0,0,0.12);
  overflow: hidden;
}
.room-frame img { width: 100%; height: 100%; object-fit: cover; }
#my-room-photos-label { font-size: 9px; color: #907060; text-align: center; margin-top: 2px; }

/* Hanging lamp */
#my-room-lamp { position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
#lamp-cord { width: 2px; height: 30px; background: #9a8070; }
#lamp-shade { width: 40px; height: 20px; background: linear-gradient(180deg, #c4a07a, #a07858); border-radius: 0 0 20px 20px; box-shadow: 0 4px 12px rgba(200,160,80,0.3); }

/* Art / decoration on wall */
#my-room-art {
  flex: 1; display: flex; justify-content: flex-end; padding-top: 12px;
}
#art-inner {
  width: 60px; height: 70px; border: 3px solid #b0988a; background: #e0d8d0;
  border-radius: 2px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #b0988a; box-shadow: 1px 2px 6px rgba(0,0,0,0.1);
}

/* Bed */
#my-room-bed { display: flex; flex-direction: column; align-items: flex-start; flex-shrink: 0; }
#bed-headboard {
  width: 110px; 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);
}
#bed-body {
  width: 110px; height: 56px; background: #e8e0d8; border: 2px solid #c8b8a8;
  display: flex; gap: 0; overflow: hidden; flex-direction: column;
}
#bed-pillow { height: 20px; background: #f5f0ea; border-bottom: 1px solid #d8ccc0; margin: 4px 6px 2px; border-radius: 4px; }
#bed-blanket { flex: 1; background: linear-gradient(135deg, #c4a58a, #b89478); }

/* Desk */
#my-room-desk-area { flex: 1; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; padding-right: 8px; }
#my-room-desk {
  width: 130px; height: 50px; background: linear-gradient(180deg, #8b6445, #7a5538);
  border-radius: 4px 4px 0 0; position: relative;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
  display: flex; align-items: flex-start; padding: 6px 8px; gap: 8px;
}
#desk-lamp { display: flex; flex-direction: column; align-items: center; }
#desk-lamp-arm { width: 2px; height: 18px; background: #c4a07a; transform: rotate(-10deg); }
#desk-lamp-head { width: 16px; height: 8px; background: #e8c87a; border-radius: 0 0 8px 8px; }
#desk-diary {
  flex: 1; height: 34px; background: linear-gradient(135deg, #5a4030, #3d2820);
  border-radius: 2px 3px 3px 2px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
  position: relative;
}
#desk-diary::before { content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: #8b6445; }
#diary-cover { font-size: 8px; color: #d4c0a8; letter-spacing: 1px; }
#desk-diary:hover { filter: brightness(1.15); }
#desk-cup {
  width: 14px; height: 18px; background: #e8e0d8; border: 1px solid #c8b8a8;
  border-radius: 0 0 3px 3px; align-self: flex-end;
}
#desk-legs { width: 130px; display: flex; justify-content: space-between; padding: 0 12px; }
#desk-legs div { width: 6px; height: 20px; background: #7a5538; }

/* Panels */
#room-diary-panel, #room-photos-panel {
  display: none; position: absolute; inset: 0; background: var(--bg); flex-direction: column; z-index: 10;
}
#room-diary-panel.active, #room-photos-panel.active { display: flex; }
#room-diary-panel-header, #room-photos-panel-header {
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; font-size: 15px; font-weight: 600;
}
#diary-panel-back, #photos-panel-back, #diary-panel-add, #photos-panel-add {
  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;
}
#diary-panel-back svg, #photos-panel-back svg { width: 16px; height: 16px; stroke: var(--text-muted); }
#diary-panel-add svg, #photos-panel-add svg { width: 16px; height: 16px; stroke: var(--text); }
#room-diary-list { flex: 1; overflow-y: auto; }
#room-photo-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3,1fr); gap: 2px; padding: 2px; align-content: start; }

/* Diary/photo add modals */
#diary-add-modal, #photo-add-modal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 400; align-items: flex-end; justify-content: center;
}
#diary-add-modal.active, #photo-add-modal.active { display: flex; }
#diary-add-inner, #photo-add-inner {
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px 20px 36px;
  width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 12px;
}
#room-diary-input { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); width: 100%; resize: none; }
#room-photo-caption, #room-photo-drop { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); width: 100%; }
#room-photo-drop { border-style: dashed; text-align: center; color: var(--text-muted); cursor: pointer; padding: 30px; }
#room-photo-drop.has-file { border-color: var(--send-bg); color: var(--send-bg); border-style: solid; }
#room-modal-actions, #room-modal-actions2 { display: flex; gap: 10px; }
#room-cancel-btn, #photo-cancel-btn { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: none; color: var(--text); font-size: 14px; cursor: pointer; }
#room-save-btn, #photo-save-btn { flex: 1; padding: 12px; border-radius: 10px; border: none; background: var(--send-bg); color: #fff; font-size: 14px; cursor: pointer; }

/* Lock overlay */
#room-locked-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 250; align-items: center; justify-content: center;
}
#room-locked-overlay.active { display: flex; }
#room-locked-inner {
  background: var(--bg); border-radius: 20px; padding: 32px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: 260px; text-align: center;
}
#room-lock-icon { font-size: 40px; }
#room-lock-text { font-size: 15px; font-weight: 600; color: var(--text); }
#room-knock-btn {
  width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--send-bg); color: #fff; font-size: 15px; cursor: pointer;
}
#room-lock-cancel {
  background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer;
}

/* Room page */
#room-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; }
#room-add-btn svg { width: 16px; height: 16px; stroke: var(--text); }
#room-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.room-tab { flex: 1; padding: 10px; border: none; background: none; font-size: 14px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.room-tab.active { color: var(--send-bg); border-bottom-color: var(--send-bg); font-weight: 600; }
#room-page-body { flex: 1; overflow-y: auto; }
#room-photo-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 2px; padding: 2px; }
.room-photo-cell { aspect-ratio: 1; overflow: hidden; position: relative; cursor: pointer; background: var(--surface); }
.room-photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.room-photo-del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,0.5); border: none; color: #fff; font-size: 14px; cursor: pointer; display: none; align-items: center; justify-content: center; }
.room-photo-cell:hover .room-photo-del { display: flex; }
#room-diary-list { display: flex; flex-direction: column; gap: 0; }
.room-diary-entry { padding: 16px; border-bottom: 1px solid var(--border); }
.room-diary-date { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.room-diary-text { font-size: 14px; line-height: 1.7; white-space: pre-wrap; color: var(--text); }
.room-diary-del { float: right; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 0; margin-left: 8px; }
#room-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px; }
/* Lightbox */
#room-lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 400; align-items: center; justify-content: center; flex-direction: column; gap: 12px; }
#room-lightbox.active { display: flex; }
#room-lightbox-img { max-width: 95vw; max-height: 80vh; object-fit: contain; border-radius: 8px; }
#room-lightbox-close { position: absolute; top: 16px; right: 16px; color: #fff; font-size: 28px; cursor: pointer; }
#room-lightbox-caption { color: rgba(255,255,255,0.7); font-size: 13px; }
/* Add modal */
#room-add-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300; align-items: flex-end; justify-content: center; }
#room-add-modal.active { display: flex; }
#room-add-inner { background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px 20px 36px; width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 12px; }
#room-add-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.room-add-tab { flex: 1; padding: 8px; border: none; background: none; font-size: 13px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.room-add-tab.active { color: var(--send-bg); border-bottom-color: var(--send-bg); font-weight: 600; }
#room-photo-drop { border: 2px dashed var(--border); border-radius: 12px; padding: 30px; text-align: center; color: var(--text-muted); font-size: 14px; cursor: pointer; }
#room-photo-drop.has-file { border-color: var(--send-bg); color: var(--send-bg); }
#room-photo-caption, #room-diary-input { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); width: 100%; }
#room-modal-actions { display: flex; gap: 10px; }
#room-cancel-btn { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: none; color: var(--text); font-size: 14px; cursor: pointer; }
#room-save-btn { flex: 1; padding: 12px; border-radius: 10px; border: none; background: var(--send-bg); color: #fff; font-size: 14px; cursor: pointer; }

/* ========== 知臨房間 Photo Mode ========== */
#room-page.room-photo #room-page-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
  color: #fff;
  border-bottom: none;
}
#room-page.room-photo #room-page-header button { color: #fff; }
#room-page.room-photo #room-page-header span { color: #fff; }

#room-page.room-photo #my-room-scene {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
#room-page.room-night #my-room-scene {
  background-image: url('/images/room_caelum_night.jpg');
}
#room-page.room-morning #my-room-scene {
  background-image: url('/images/room_caelum_morning.jpg');
}
#room-page.room-photo #my-room-wall,
#room-page.room-photo #my-room-baseboard,
#room-page.room-photo #my-room-floor { display: none; }

#room-page.room-photo #room-diary-area,
#room-page.room-photo #room-photos-area { display: none; }

/* photo-mode labels */
.caelum-photo-label {
  display: none;
  position: absolute;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  padding: 5px 12px;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 10;
}
#room-page.room-photo .caelum-photo-label { display: block; }

#caelum-label-diary { top: 56%; left: 30%; }
#caelum-label-photos { top: 23%; left: 37%; }

/* bottom action bar */
#caelum-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;
}
#room-page.room-photo #caelum-photo-bar { display: flex; }

#caelum-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;
}
#caelum-photo-bar button:active { background: rgba(255,255,255,0.35); }

/* active sub-panels sit above the absolute header */
#room-page.room-photo #room-diary-panel.active,
#room-page.room-photo #room-photos-panel.active { z-index: 30; }

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

