/* ===== 基础重置与变量 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --sidebar:   #1d1d1f;
  --sidebar-t: #f5f5f7;
  --accent:    #0071e3;
  --accent-l:  #e8f2ff;
  --green:     #34c759;
  --orange:    #ff9f0a;
  --red:       #ff453a;
  --text:      #1d1d1f;
  --text2:     #6e6e73;
  --text3:     #aeaeb2;
  --border:    #e5e5ea;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --fish-bg:   #e3f2fd;
  --fish-border: #bbdefb;
  --cat-bg:    #f1f8e9;
  --cat-border: #c5e1a5;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ===== 布局 ===== */
.app { display: flex; height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar);
  color: var(--sidebar-t);
  display: flex;
  flex-direction: column;
  padding: 28px 20px 20px;
  overflow-y: auto;
}

.sidebar-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}
.logo { font-size: 1rem; font-weight: 700; letter-spacing: .5px; line-height: 1.5; }
.subtitle { font-size: .85rem; opacity: .4; margin-top: 6px; letter-spacing: 3px; }

.sync-section { margin-top: 0; }

.sync-btns {
  display: flex;
  gap: 6px;
}

.btn-sync {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 6px;
  color: rgba(255,255,255,.85);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  font-size: .74rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .15s, opacity .2s;
  white-space: nowrap;
  background: rgba(255,255,255,.06);
}
.btn-sync:disabled { opacity: .5; cursor: not-allowed; }
.btn-sync:active { transform: scale(.97); }
.btn-sync.syncing .sync-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-sync:hover:not(:disabled) {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.25);
  color: #fff;
}

.sync-icon { display: inline-block; font-size: .85rem; }
.sync-info { font-size: .68rem; opacity: .35; margin-top: 6px; text-align: center; }

.stats {
  margin-top: 20px;
  padding: 14px;
  background: rgba(255,255,255,.07);
  border-radius: 10px;
  font-size: .82rem;
  line-height: 1.7;
}

/* ===== 侧边栏时间线 ===== */
.timeline-nav {
  margin-top: 24px;
  flex: 1;
  overflow-y: auto;
  padding-left: 14px;
  position: relative;
}

/* 纵线 */
.timeline-nav::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(255,255,255,.12);
  border-radius: 1px;
}

/* ---- 年份节点 ---- */
.tl-year-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
}

.tl-year-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.4);
  flex-shrink: 0;
  z-index: 1;
  transition: all .2s;
}
.tl-year-node:hover .tl-year-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.tl-year-text {
  font-size: .82rem;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  letter-spacing: .03em;
}
.tl-year-node:hover .tl-year-text { color: #fff; }

/* ---- 月份节点 ---- */
.tl-month-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 0 5px 4px;
  cursor: pointer;
  transition: all .15s;
  border-radius: 6px;
  margin: 1px 0;
}
.tl-month-node:hover {
  background: rgba(255,255,255,.06);
}

.tl-month-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  flex-shrink: 0;
  z-index: 1;
  transition: all .2s;
  margin-left: 4px;
}
.tl-month-node:hover .tl-month-dot {
  background: rgba(255,255,255,.5);
  transform: scale(1.3);
}

.tl-month-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

.tl-month-name {
  font-size: .8rem;
  color: rgba(255,255,255,.6);
  transition: color .15s;
}
.tl-month-node:hover .tl-month-name { color: rgba(255,255,255,.9); }

.tl-month-count {
  font-size: .65rem;
  color: rgba(255,255,255,.3);
  white-space: nowrap;
}

/* ---- 激活态 ---- */
.tl-month-node.active {
  background: rgba(0,113,227,.2);
}
.tl-month-node.active .tl-month-dot {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0,113,227,.6);
  transform: scale(1.4);
}
.tl-month-node.active .tl-month-name {
  color: #fff;
  font-weight: 600;
}
.tl-month-node.active .tl-month-count {
  color: rgba(255,255,255,.6);
}

/* ===== 主区域 ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 36px;
  overflow: hidden;
}

/* ===== 日历头部 ===== */
.calendar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-panel {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.search-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 10px;
}

.search-box:focus-within {
  border-color: rgba(0,113,227,.25);
  background: #fff;
}

.search-icon {
  color: var(--text2);
  font-size: .95rem;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  height: 40px;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--text);
  outline: none;
}

.search-input::placeholder { color: var(--text3); }

.search-clear,
.search-close-btn {
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.search-clear {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--text2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, background .15s;
}

.search-clear.visible {
  opacity: 1;
  pointer-events: all;
}

.search-clear:hover,
.search-close-btn:hover {
  background: rgba(0,113,227,.08);
}

.search-close-btn {
  display: none;
  color: var(--text2);
  padding: 8px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

.search-summary {
  margin-top: 10px;
  font-size: .78rem;
  color: var(--text2);
}

.search-results {
  display: none;
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
  gap: 8px;
}

.search-results.open {
  display: grid;
}

.search-result-item {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}

.search-result-item:hover {
  border-color: rgba(0,113,227,.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}

.search-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-result-date {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text);
}

.search-result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.search-badge {
  font-size: .65rem;
  color: var(--accent);
  background: var(--accent-l);
  padding: 2px 6px;
  border-radius: 999px;
}

.search-result-preview {
  margin-top: 6px;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--text2);
}

.search-empty {
  border: 1px dashed var(--border);
  background: rgba(255,255,255,.65);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: var(--text2);
  font-size: .82rem;
}

.month-picker-wrap {
  position: relative;
}

.month-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.03em;
  min-width: 180px;
  text-align: center;
  cursor: pointer;
  padding: 4px 14px;
  border-radius: 10px;
  transition: background .15s;
  user-select: none;
}
.month-title:hover { background: var(--accent-l); }
.month-title.active { background: var(--accent-l); color: var(--accent); }

/* ===== 月份选择器弹窗 ===== */
.month-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(.95);
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.08);
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
}
.month-picker.open {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) scale(1);
}

.picker-year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.picker-year {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.picker-arrow {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  font-family: inherit;
}
.picker-arrow:hover { background: var(--accent-l); }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.picker-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  border: 2px solid transparent;
  position: relative;
}
.picker-cell:hover {
  background: var(--bg);
}
.picker-cell.selected {
  background: var(--accent);
  color: #fff;
}
.picker-cell.today:not(.selected) {
  border-color: var(--accent);
}
.picker-cell.has-data:not(.selected) {
  background: rgba(0,113,227,.06);
}

.picker-month-label {
  font-size: .85rem;
  font-weight: 600;
}

.picker-dot {
  font-size: .6rem;
  background: var(--accent);
  color: #fff;
  padding: 0 5px;
  border-radius: 6px;
  line-height: 1.5;
  min-width: 16px;
  text-align: center;
}
.picker-cell.selected .picker-dot {
  background: rgba(255,255,255,.35);
}

/* ===== 导航按钮 ===== */
.nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.nav-btn:hover { background: var(--accent-l); }

.today-btn {
  width: auto;
  padding: 0 14px;
  font-size: .82rem;
  font-weight: 600;
  margin-left: auto;
}

/* ===== 星期行 ===== */
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.weekday {
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text2);
  padding: 6px 0;
}
.weekday.sun { color: var(--red); }
.weekday.sat { color: var(--accent); }

/* ===== 日历网格 ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 6px;
  flex: 1;
}

.day-cell {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 80px;
  position: relative;
  cursor: default;
  transition: transform .15s, box-shadow .2s;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.day-cell.empty { background: transparent; border: none; }
.day-cell.has-entry {
  cursor: pointer;
  border-color: var(--accent-l);
}
.day-cell.has-entry:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.day-cell.search-hit {
  border-color: rgba(0,113,227,.35);
  box-shadow: inset 0 0 0 1px rgba(0,113,227,.12);
}
.day-cell.today {
  border-color: var(--accent);
  background: var(--accent-l);
}

/* ---- 纪念日彩蛋 ---- */
.day-cell.anniversary {
  border-color: #f48fb1;
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
  position: relative;
}
.day-cell.anniversary:hover {
  border-color: #ec407a;
  box-shadow: 0 2px 12px rgba(236,64,122,.25);
}
.day-cell.anniversary .day-num {
  color: #c2185b;
}

.anniversary-badge {
  display: block;
  font-size: .55rem;
  line-height: 1.2;
  margin-top: 2px;
  color: #c2185b;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anniversary-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 50%, #f3e5f5 100%);
  border-radius: 14px;
  animation: bannerGlow 3s ease-in-out infinite alternate;
}
@keyframes bannerGlow {
  0%   { box-shadow: 0 0 8px rgba(236,64,122,.15); }
  100% { box-shadow: 0 0 20px rgba(236,64,122,.3); }
}
.anniversary-emoji {
  font-size: 1.3rem;
  animation: heartBeat 1.2s ease-in-out infinite;
}
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  30%      { transform: scale(1.15); }
  60%      { transform: scale(1); }
}
.anniversary-text {
  font-size: .88rem;
  font-weight: 600;
  color: #880e4f;
  letter-spacing: .02em;
}

.day-num { font-size: .9rem; font-weight: 600; color: var(--text); }
.day-cell.empty .day-num { color: var(--text3); }
.day-cell.sun .day-num { color: var(--red); }
.day-cell.sat .day-num { color: var(--accent); }

.day-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  top: 12px; right: 10px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.day-preview {
  margin-top: 6px;
  font-size: .72rem;
  color: var(--text2);
  line-height: 1.4;
  overflow: hidden;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ===== 详情面板 ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  z-index: 90;
}
.overlay.open { opacity: 1; pointer-events: all; }

.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 580px; max-width: 92vw;
  background: var(--bg);
  box-shadow: -4px 0 30px rgba(0,0,0,.15);
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  z-index: 100;
  display: flex; flex-direction: column;
}
.detail-panel.open { transform: translateX(0); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.panel-header-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-header h2 { font-size: 1.1rem; font-weight: 700; }
.panel-nav-row {
  display: flex;
  gap: 8px;
}
.panel-nav-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text2);
  border-radius: 10px;
  padding: 6px 10px;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  transition: all .15s;
}
.panel-nav-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(0,113,227,.2);
  background: var(--accent-l);
}
.panel-nav-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.panel-close {
  width: 32px; height: 32px;
  border: none; border-radius: 8px;
  background: var(--bg);
  font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.panel-close:hover { background: #e0e0e0; }

.panel-content {
  flex: 1; overflow-y: auto;
  padding: 16px 20px 40px;
  line-height: 1.75; font-size: .88rem;
}

/* ===== 聊天气泡 ===== */
.chat-msg {
  display: flex; align-items: flex-start;
  gap: 10px; margin-bottom: 6px;
  animation: msgIn .25s ease-out;
}
.chat-msg.consecutive { margin-bottom: 3px; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-avatar {
  width: 36px; min-width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.chat-msg.consecutive .chat-avatar { visibility: hidden; }
.chat-msg.fish .chat-avatar { background: var(--fish-bg); }
.chat-msg.cat .chat-avatar  { background: var(--cat-bg); }

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.7;
  word-break: break-word;
}
.chat-msg.fish .chat-bubble {
  background: var(--fish-bg); border: 1px solid var(--fish-border);
  border-top-left-radius: 4px; color: #1a3a5c;
}
.chat-msg.fish.consecutive .chat-bubble { border-top-left-radius: 16px; }
.chat-msg.cat { flex-direction: row-reverse; }
.chat-msg.cat .chat-bubble {
  background: var(--cat-bg); border: 1px solid var(--cat-border);
  border-top-right-radius: 4px; color: #2e4a1e;
}
.chat-msg.cat.consecutive .chat-bubble { border-top-right-radius: 16px; }

.chat-bubble strong { font-weight: 700; }
.chat-bubble del { opacity: .55; }
.chat-bubble a { color: var(--accent); text-decoration: none; }
.chat-bubble a:hover { text-decoration: underline; }
.chat-bubble u { text-decoration-color: var(--accent); }
.chat-bubble img { max-width: 100%; border-radius: 8px; margin: 6px 0; cursor: pointer; }

.panel-content .chat-bubble blockquote {
  border-left: 3px solid currentColor;
  opacity: .75;
  padding: 4px 10px;
  margin: 6px 0 2px;
  border-radius: 0 6px 6px 0;
  background: rgba(0,0,0,.04);
  font-size: .84em;
  color: inherit;
}

.chat-time-wrap {
  text-align: center;
  margin: 16px 0 10px;
}
.chat-time-bubble {
  font-size: .7rem;
  color: var(--text3);
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-block;
  padding: 2px 12px;
  border-radius: 10px;
  letter-spacing: .5px;
}

.chat-tail {
  text-align: center;
  margin: 28px 0 10px;
  font-size: .8rem;
  color: var(--text3);
  opacity: .5;
  letter-spacing: 3px;
}

.chat-system { text-align: center; margin: 12px 0; padding: 0 20px; }
.chat-system p {
  display: inline-block;
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 12px;
  font-size: .82rem; color: var(--text2);
  line-height: 1.65; text-align: left; max-width: 100%;
}

/* panel extras */
.panel-content h1 { font-size: 1.3rem; margin: 16px 0 8px; }
.panel-content h2 { font-size: 1.15rem; margin: 14px 0 6px; }
.panel-content h3 { font-size: 1rem; margin: 12px 0 6px; }
.panel-content blockquote {
  border-left: 3px solid var(--accent); padding: 8px 14px; margin: 10px 0;
  background: var(--accent-l); border-radius: 0 8px 8px 0;
  color: var(--text2); font-size: .85rem;
}
.panel-content pre {
  background: #1d1d1f; color: #f5f5f7; padding: 14px; border-radius: 10px;
  overflow-x: auto; margin: 10px 0; font-size: .8rem; line-height: 1.6;
}
.panel-content code { background: var(--accent-l); padding: 2px 5px; border-radius: 4px; font-size: .84em; }
.panel-content pre code { background: transparent; padding: 0; }
.panel-content li { margin-left: 20px; margin-bottom: 4px; }
.panel-content hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.panel-content .todo-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.panel-content .mention { color: var(--accent); font-weight: 600; }
.panel-content .image-block img { max-width: 100%; border-radius: 10px; margin: 8px 0; box-shadow: 0 1px 6px rgba(0,0,0,.1); }
.search-mark {
  background: #fff1a8;
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}

/* empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text3); font-size: .95rem; text-align: center; gap: 8px;
}
.empty-state .icon { font-size: 3rem; }

/* toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15); font-size: .85rem;
  transform: translateX(120%);
  animation: slideIn .3s forwards, slideOut .3s 3s forwards;
  max-width: 340px;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--accent); }
@keyframes slideIn { to { transform: translateX(0); } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ===== 侧边栏遮罩 ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  z-index: 49;
  opacity: 0;
  transition: opacity .3s;
}
.sidebar-overlay.open { opacity: 1; }

.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  z-index: 69;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* 汉堡按钮默认隐藏 */
.menu-btn { display: none; }
.mobile-actions { display: none; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .sidebar { width: 220px; min-width: 220px; padding: 20px 14px; }
  .main { padding: 20px; }
  .month-title { font-size: 1.2rem; min-width: 140px; }
  .day-cell { min-height: 0; padding: 6px; }
  .day-preview { -webkit-line-clamp: 2; font-size: .68rem; }
  .month-picker { width: 250px; }
  .search-panel { padding: 10px; }
  .search-bar-row { gap: 8px; }
}

@media (max-width: 640px) {
  body { overflow: auto; }

  /* 汉堡按钮 */
  .menu-btn {
    display: flex;
    font-size: 1.2rem;
    flex-shrink: 0;
  }

  /* 侧边栏变抽屉 */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 270px; min-width: 270px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    padding: 24px 18px 18px;
    flex-direction: column;
    overflow-y: auto;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar-overlay {
    display: block;
    pointer-events: none;
    opacity: 0;
  }
  .sidebar-overlay.open {
    pointer-events: all;
    opacity: 1;
  }

  .sidebar-header { flex: none; }
  .sync-section { margin-top: 18px; }
  .sync-btns { flex-direction: column; gap: 8px; }
  .btn-sync { padding: 10px 12px; font-size: .82rem; justify-content: center; }

  /* 主区域 */
  .main {
    padding: 14px 10px;
    overflow-y: auto;
    width: 100%;
    padding-bottom: 82px;
  }

  /* 日历头部 */
  .calendar-header {
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }
  .month-title { font-size: 1.1rem; min-width: 0; padding: 4px 8px; }
  .nav-btn { width: 32px; height: 32px; font-size: 1rem; }
  .today-btn { display: none; }

  /* 搜索面板 */
  .search-overlay { display: block; }
  .search-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 74px;
    z-index: 70;
    margin-bottom: 0;
    border-radius: 18px;
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform .28s cubic-bezier(.4,0,.2,1), opacity .2s;
    max-height: calc(100vh - 120px);
    overflow: auto;
  }
  .search-panel.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }
  .search-close-btn { display: inline-flex; align-items: center; justify-content: center; }
  .search-bar-row {
    align-items: stretch;
  }
  .search-box {
    min-width: 0;
  }
  .search-input {
    font-size: 16px;
  }
  .search-results {
    max-height: 42vh;
  }

  /* 月份选择器 */
  .month-picker {
    width: calc(100vw - 40px);
    max-width: 320px;
    left: 50%;
  }

  /* 星期行 */
  .weekday-row { gap: 2px; margin-bottom: 4px; }
  .weekday { font-size: .7rem; padding: 4px 0; }

  /* 日历网格 */
  .calendar-grid {
    gap: 3px;
    min-height: calc(100vh - 190px);
  }
  .day-cell {
    min-height: 0;
    padding: 6px 5px;
    border-radius: 8px;
  }
  .day-cell.has-entry {
    background: var(--accent-l);
    border-color: rgba(0,113,227,.2);
  }
  .day-num { font-size: .82rem; }
  .day-dot { width: 6px; height: 6px; top: 6px; right: 5px; }
  .day-preview {
    display: -webkit-box;
    font-size: .6rem;
    line-height: 1.3;
    margin-top: 3px;
    -webkit-line-clamp: 2;
    color: var(--text2);
    opacity: .7;
  }

  /* 详情面板 */
  .detail-panel { width: 100vw; max-width: 100vw; }
  .panel-header { padding: 14px 16px 10px; }
  .panel-header h2 { font-size: .95rem; }
  .panel-nav-row { gap: 6px; flex-wrap: wrap; }
  .panel-nav-btn { font-size: .74rem; padding: 6px 9px; }
  .panel-content { padding: 12px 14px calc(30px + env(safe-area-inset-bottom, 20px)); font-size: .85rem; }

  /* 聊天气泡 */
  .chat-avatar { width: 30px; min-width: 30px; height: 30px; font-size: 1.1rem; }
  .chat-bubble { max-width: 88%; padding: 8px 12px; font-size: .84rem; }
  .chat-msg { gap: 6px; }

  /* 底部快捷栏 */
  .mobile-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 75;
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(255,255,255,.85);
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 8px;
  }
  .mobile-action-btn {
    border: none;
    background: transparent;
    border-radius: 12px;
    padding: 10px 6px;
    color: var(--text2);
    font: inherit;
    cursor: pointer;
    transition: background .15s, color .15s;
  }
  .mobile-action-btn:hover,
  .mobile-action-btn:active {
    background: var(--accent-l);
    color: var(--accent);
  }
  .mobile-action-label {
    font-size: .78rem;
    font-weight: 600;
  }

  /* toast */
  .toast-container { top: 10px; right: 10px; left: 10px; }
  .toast { max-width: unset; font-size: .8rem; padding: 10px 14px; }
}

/* ===== 角色选择弹窗 ===== */
.role-modal {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(252,228,236,.85), rgba(227,242,253,.85));
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .4s;
}
.role-modal.open { opacity: 1; pointer-events: all; }

.role-modal-card {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(244,143,177,.25);
  border-radius: 28px;
  padding: 44px 36px 38px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(236,64,122,.12), 0 0 80px rgba(244,143,177,.1);
  max-width: 380px;
  width: 90vw;
  transform: scale(.88) translateY(20px);
  transition: transform .4s cubic-bezier(.4,0,.2,1);
}
.role-modal.open .role-modal-card { transform: scale(1) translateY(0); }

.role-modal-hearts {
  font-size: 1.6rem;
  margin-bottom: 14px;
  letter-spacing: 4px;
  animation: heartFloat 2.5s ease-in-out infinite;
}
@keyframes heartFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.role-modal-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #37474f;
}
.role-modal-sub {
  font-size: .84rem;
  color: #90a4ae;
  margin-bottom: 30px;
  line-height: 1.5;
}
.role-modal-btns {
  display: flex; gap: 16px; justify-content: center;
}
.role-btn {
  flex: 1;
  border: 2px solid transparent;
  border-radius: 20px;
  padding: 26px 16px;
  cursor: pointer;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  position: relative;
  overflow: hidden;
}
.role-btn-fish {
  background: linear-gradient(145deg, #e3f2fd, #bbdefb);
  border-color: rgba(100,181,246,.3);
}
.role-btn-cat {
  background: linear-gradient(145deg, #e8f5e9, #c8e6c9);
  border-color: rgba(129,199,132,.3);
}
.role-btn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 10px 30px rgba(0,0,0,.1);
}
.role-btn-fish:hover {
  border-color: #64b5f6;
  box-shadow: 0 10px 30px rgba(100,181,246,.25);
}
.role-btn-cat:hover {
  border-color: #81c784;
  box-shadow: 0 10px 30px rgba(129,199,132,.25);
}
.role-btn:active { transform: translateY(-1px) scale(.98); }
.role-emoji { font-size: 3rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.1)); }
.role-label { font-size: .95rem; font-weight: 600; color: #455a64; }

/* ===== 侧边栏角色切换 ===== */
.role-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
  transition: all .15s;
  font-size: .78rem;
  color: rgba(255,255,255,.7);
}
.role-switch:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.12);
  color: rgba(255,255,255,.9);
}

/* ===== 视角切换：鱼鱼视角 ===== */
body.perspective-fish .chat-msg.fish { flex-direction: row-reverse; }
body.perspective-fish .chat-msg.cat  { flex-direction: row; }

body.perspective-fish .chat-msg.fish .chat-bubble {
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
}
body.perspective-fish .chat-msg.fish.consecutive .chat-bubble {
  border-top-right-radius: 16px;
}
body.perspective-fish .chat-msg.cat .chat-bubble {
  border-top-right-radius: 16px;
  border-top-left-radius: 4px;
}
body.perspective-fish .chat-msg.cat.consecutive .chat-bubble {
  border-top-left-radius: 16px;
}

/* ===== 页面装饰 ===== */
.deco-fish, .deco-cat {
  position: fixed;
  font-size: 2rem;
  opacity: .06;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}
.deco-fish {
  bottom: 30px; left: 40px;
  animation: decoSwim 6s ease-in-out infinite;
}
.deco-cat {
  top: 30px; right: 40px;
  animation: decoFloat 5s ease-in-out infinite;
}
@keyframes decoSwim {
  0%, 100% { transform: translateX(0) rotate(-5deg); }
  50% { transform: translateX(12px) rotate(5deg); }
}
@keyframes decoFloat {
  0%, 100% { transform: translateY(0) rotate(5deg); }
  50% { transform: translateY(-10px) rotate(-3deg); }
}

/* 移动端底部栏 icon */
.mobile-action-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }
