/* ========== pages.css ==========
   Calendar page, Settings page, Memory page
   ============================== */

/* Calendar page */
#calendar-page {
  display: none; position: fixed; inset: 0;
  background: var(--bg); z-index: 200; flex-direction: column;
}
#calendar-page.active { display: flex; }
#calendar-page-header {
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#calendar-back-btn, #calendar-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; flex-shrink: 0;
}
#calendar-back-btn svg { width: 16px; height: 16px; stroke: var(--text-muted); }
#calendar-add-btn svg { width: 16px; height: 16px; stroke: var(--text); }
#calendar-page-title { font-size: 15px; font-weight: 600; flex: 1; }
#calendar-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
#cal-nav { display: flex; align-items: center; justify-content: space-between; }
#cal-nav button { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); padding: 4px 10px; }
#cal-month-label { font-size: 16px; font-weight: 600; }
#cal-weekdays { display: grid; grid-template-columns: repeat(7,1fr); text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
#cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 14px; cursor: pointer; position: relative; flex-direction: column;
}
.cal-cell:hover { background: var(--surface); }
.cal-cell.today { background: var(--bubble-user); color: #fff; font-weight: 600; }
.cal-cell.selected { outline: 2px solid var(--send-bg); }
.cal-cell.has-event::after {
  content: ''; position: absolute; bottom: 3px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--send-bg);
}
.cal-cell.today.has-event::after { background: #fff; }
.cal-cell.other-month { opacity: 0.3; }
.cal-cell.anniversary { color: #c0392b; font-weight: 700; }
.cal-cell.anniversary::before { content: '♡'; position: absolute; top: 0px; right: 1px; font-size: 7px; color: #e07070; }
#cal-anniversary-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; background: linear-gradient(135deg, #fdf0f0, #fef5f0);
  border-radius: 12px; border: 1px solid #f0d0d0; margin: 2px 0;
}
#cal-anni-heart { font-size: 16px; color: #e07070; animation: heartbeat 1.5s ease-in-out infinite; }
@keyframes heartbeat { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }
#cal-anni-text { font-size: 13px; color: #a05050; font-weight: 500; }
#cal-day-events { background: var(--surface); border-radius: 12px; padding: 12px; min-height: 80px; }
#cal-day-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.cal-event-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.cal-event-row:last-child { border-bottom: none; }
.cal-event-time { font-size: 12px; color: var(--text-muted); min-width: 36px; }
.cal-event-title { flex: 1; font-size: 14px; }
.cal-event-del { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; padding: 0 4px; }
#cal-day-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 16px 0; }
#cal-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;
}
#cal-add-modal.active { display: flex; }
#cal-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;
}
.cal-modal-title { font-size: 15px; font-weight: 600; }
#cal-add-inner input, #cal-add-inner textarea {
  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%;
}
#cal-modal-actions { display: flex; gap: 10px; }
#cal-cancel-btn { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: none; color: var(--text); font-size: 14px; cursor: pointer; }
#cal-save-btn { flex: 1; padding: 12px; border-radius: 10px; border: none; background: var(--send-bg); color: #fff; font-size: 14px; cursor: pointer; }
.cal-type-btn { flex:1; padding:8px; border-radius:8px; border:1px solid var(--border); background:none; color:var(--text-muted); font-size:13px; cursor:pointer; }
.cal-type-btn.active { background:var(--send-bg); color:#fff; border-color:var(--send-bg); }
.cal-cell.has-reminder::before { content:''; position:absolute; top:3px; right:3px; width:4px; height:4px; border-radius:50%; background:#e07070; }

/* 便利條 sticky notes */
#cal-daily-notes {
  display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 0;
}
#cal-daily-notes-label {
  font-size: 12px; color: var(--text-muted); margin-bottom: 2px; letter-spacing: 0.4px;
}
.sticky-note {
  background: #fef08a; color: #3d3000;
  border-radius: 3px 12px 12px 3px;
  padding: 10px 12px 10px 10px;
  font-size: 13px; line-height: 1.5;
  min-width: 90px; max-width: 140px;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.15), inset -2px 0 0 rgba(0,0,0,0.06);
  position: relative; cursor: default;
  word-break: break-word;
}
.sticky-note:nth-child(odd) { transform: rotate(-1.2deg); }
.sticky-note:nth-child(even) { transform: rotate(0.8deg); }
.sticky-note-time { font-size: 11px; color: #7a6000; margin-bottom: 3px; }
.sticky-note-title { font-weight: 600; font-size: 13px; }
.sticky-note-note { font-size: 11px; color: #5a4800; margin-top: 3px; }
.sticky-note-del {
  position: absolute; top: 4px; right: 5px;
  background: none; border: none; cursor: pointer;
  color: #a08000; font-size: 13px; line-height: 1; padding: 0;
  opacity: 0.4;
}
.sticky-note-del:hover { opacity: 1; }
.sticky-note-check {
  position: absolute; bottom: 5px; right: 6px;
  background: none; border: none; cursor: pointer;
  color: #8a7000; font-size: 14px; line-height: 1; padding: 0;
  opacity: 0.5;
}
.sticky-note-check:hover { opacity: 1; }
.sticky-note-check.checked { color: #3a7a00; opacity: 0.9; font-weight: bold; }
.sticky-note.done { background: #f5f0c0; }
.sticky-note.done .sticky-note-title { text-decoration: line-through; opacity: 0.55; }
/* day reminders as sticky notes too */
.cal-day-sticky-wrap { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
#cal-daily-toggle {
  font-size: 13px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer;
  display: none;
}
#cal-daily-toggle.visible { display: inline-block; }
#cal-daily-toggle.on { background: #fef08a; color: #3d3000; border-color: #d4c020; }

#settings-page {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  flex-direction: column;
}
#settings-page.active { display: flex; }
#settings-page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#settings-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;
  flex-shrink: 0;
}
#settings-back-btn svg { width: 16px; height: 16px; stroke: var(--text-muted); }
#settings-page-title { font-size: 15px; font-weight: 600; flex: 1; }
#settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.settings-title { font-size: 15px; font-weight: 600; }
.ctx-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ctx-opt {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.ctx-opt.active { background: var(--send-bg); color: #fff; border-color: var(--send-bg); }
.tts-opt {
  padding: 8px 18px; border-radius: 20px; border: 1px solid var(--border);
  background: none; cursor: pointer; font-size: 13px; color: var(--text);
}
.tts-opt.active { background: var(--send-bg); color: #fff; border-color: var(--send-bg); }
#settings-reset-btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid #e05555;
  background: none;
  color: #e05555;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
#settings-reset-btn:active { background: #e0555520; }

.perm-list { display: flex; flex-direction: column; gap: 10px; }
.perm-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.perm-icon { font-size: 20px; flex-shrink: 0; }
.perm-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.perm-name { font-size: 14px; font-weight: 500; }
.perm-status { font-size: 12px; }
.perm-status.granted { color: #5a9c6e; }
.perm-status.denied { color: #c05050; }
.perm-status.default { color: var(--text-muted); }
.perm-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.perm-btn.active { background: var(--send-bg); color: #fff; border-color: var(--send-bg); }
.perm-btn:disabled { opacity: 0.4; cursor: default; }

/* Memory full-page */
#memory-page {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  flex-direction: column;
  overflow: hidden;
}
#memory-page.active { display: flex; }
#memory-tabs-bar {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.mem-tab {
  flex: 1; padding: 10px 0; border: none; background: none;
  color: var(--text-muted); font-size: 13px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.mem-tab.active { color: var(--text); border-bottom-color: var(--send-bg); }
#graph-node-grid { display: flex; flex-direction: column; gap: 8px; }
.graph-group-label { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.6px; margin: 8px 0 4px; }
.graph-node-card {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
}
.graph-node-card-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.graph-node-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.graph-node-card-links { font-size: 11px; color: var(--send-bg); margin-top: 4px; }
.graph-neighbor-row {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border-radius: 8px; background: var(--surface); border: 1px solid var(--border); cursor: pointer;
}
.graph-neighbor-title { font-size: 13px; font-weight: 500; }
.graph-neighbor-reason { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.graph-neighbor-weight { font-size: 11px; color: var(--send-bg); margin-left: auto; white-space: nowrap; }
#memory-page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#memory-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;
  flex-shrink: 0;
}
#memory-back-btn svg { width: 16px; height: 16px; stroke: var(--text-muted); }
#memory-page-title { font-size: 15px; font-weight: 600; flex: 1; }
#memory-add-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--send-bg);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
#memory-add-btn svg { width: 16px; height: 16px; stroke: #fff; }
#memory-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mem-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.mem-tab.active { color: var(--text); border-bottom-color: var(--send-bg); }

/* List view */
#memory-list-view { flex: 1; overflow-y: auto; }
.mem-list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
}
.mem-list-item:active { background: var(--surface); }
.mem-list-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.mem-list-info { flex: 1; min-width: 0; }
.mem-list-name { font-size: 14px; font-weight: 500; color: var(--text); }
.mem-list-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-list-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}
.mem-list-arrow { color: var(--border); font-size: 18px; flex-shrink: 0; }

/* Detail view */
#memory-detail-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
#memory-detail-view.active { display: flex; }
#memory-list-view.hidden { display: none; }
#detail-toolbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.det-back-btn {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.det-back-btn svg { width: 12px; height: 12px; stroke: currentColor; }
#detail-edit-btn, #detail-save-btn, #detail-cancel-btn, #detail-del-btn {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
}
#detail-save-btn { background: var(--send-bg); color: #fff; border-color: var(--send-bg); }
#detail-del-btn { color: #c0392b; margin-left: auto; }
#detail-content-wrap { flex: 1; overflow-y: auto; padding: 16px; }
#detail-text { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; color: var(--text); }
#detail-edit-area {
  display: none;
  width: 100%;
  font-size: 13px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  min-height: 300px;
}

/* New entry modal */
#new-entry-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  align-items: flex-end;
}
#new-entry-modal.active { display: flex; }
#new-entry-panel {
  background: var(--bg);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#new-entry-panel h3 { font-size: 14px; font-weight: 600; }
#new-entry-panel input, #new-entry-panel textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
#new-entry-panel textarea { resize: vertical; min-height: 100px; }
.new-entry-actions { display: flex; gap: 8px; justify-content: flex-end; }
.new-entry-cancel { font-size: 13px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: none; cursor: pointer; color: var(--text-muted); }
.new-entry-submit { font-size: 13px; padding: 7px 14px; border-radius: 8px; border: none; background: var(--send-bg); color: #fff; cursor: pointer; }

.mem-edit-btn, .mem-save-btn, .mem-cancel-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
}
.mem-save-btn { background: var(--send-bg); color: #fff; border-color: var(--send-bg); }

/* From first block — unique rules not in second block */
#cal-daily-row { display:none; align-items:center; gap:8px; font-size:13px; color:var(--text-muted); }
#memory-body { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:20px; }
#graph-detail {
  display: none; position: absolute; inset: 0; background: var(--bg); z-index: 10; flex-direction: column;
}
#graph-detail.active { display: flex; }

/* Usage section */
.usage-row { margin-bottom: 14px; }
.usage-label-row {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 5px;
}
.usage-bar-wrap {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 4px;
}
.usage-bar-fill {
  height: 100%; border-radius: 4px; background: var(--send-bg);
  transition: width 0.4s ease; width: 0%;
}
.usage-sub { font-size: 12px; color: var(--text-muted); }
