/* ===== 기본 변수 (다크모드) ===== */
:root {
  --bg: #0f0f17;
  --bg-elev: #1a1a26;
  --bg-card: #20202e;
  --border: #2c2c3d;
  --text: #ececf1;
  --text-dim: #9a9aae;
  --muted: #6b6b80;
  --accent: #ff6b8a;
  --accent-2: #b76bff;
  --accent-soft: rgba(255, 107, 138, 0.15);
  --danger: #ff5e5e;
  --success: #5eda9b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + var(--safe-bottom));
}

h1, h2, h3 { margin: 0; font-weight: 700; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== 헤더 ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  background: rgba(15, 15, 23, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 8px; }
.app-header h1 { font-size: 18px; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* D-day chip */
.dday-chip {
  background: linear-gradient(135deg, rgba(255,107,138,0.25), rgba(183,107,255,0.25));
  border: 1px solid rgba(255,107,138,0.35);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  transition: transform .1s, background .15s;
  white-space: nowrap;
}
.dday-chip:active { transform: scale(0.95); }
.dday-chip #dday-chip-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 모달 닫기 X 버튼 */
.modal-close-x {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 18px;
  width: 32px; height: 32px;
  border-radius: 50%;
}
.modal-close-x:hover { background: var(--bg-card); color: var(--text); }
.modal-card { position: relative; }
.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent);
}
.icon-btn {
  background: transparent;
  color: var(--text);
  border: none;
  font-size: 20px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.icon-btn:hover, .icon-btn:active { background: var(--bg-elev); }

/* ===== 메인 ===== */
main {
  flex: 1;
  padding: 18px 18px 28px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel { display: none; animation: fadeIn .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ===== D-day 영역 ===== */
.dday-hero {
  margin: 8px 0 28px;
  padding: 32px 20px;
  text-align: center;
  background: linear-gradient(135deg, rgba(255,107,138,0.18), rgba(183,107,255,0.18));
  border: 1px solid var(--border);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}
.dday-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,107,138,0.25), transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(183,107,255,0.25), transparent 50%);
  pointer-events: none;
}
.dday-label { margin: 0; color: var(--text-dim); font-size: 13px; letter-spacing: 1px; }
.dday-hero h2 {
  font-size: 48px;
  margin: 10px 0 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  letter-spacing: -1px;
}
.dday-sub { margin: 0; color: var(--text-dim); font-size: 13px; }

/* 섹션 헤더 */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 4px 12px;
}
.section-head h3 { font-size: 15px; color: var(--text-dim); font-weight: 600; }
.btn-add {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(255,107,138,0.3);
  width: 32px; height: 32px;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.btn-add:hover { background: rgba(255,107,138,0.25); }

/* 카드 리스트 */
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; margin: 0 0 2px; font-size: 15px; }
.card-sub { margin: 0; font-size: 12px; color: var(--text-dim); }
.card-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.card-delete {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 6px;
  font-size: 16px;
}
.card-delete:hover { color: var(--danger); }

.card-item.clickable .card-main { cursor: pointer; }
.card-item.clickable:hover { border-color: rgba(255,107,138,0.4); }
.card-time {
  color: var(--accent);
  font-weight: 700;
  margin-right: 2px;
}
.muted-inline { color: var(--muted); font-size: 11px; margin-left: 4px; }

/* 위시리스트 */
.wish-item { gap: 10px; }
.wish-check {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.wish-item.done .wish-check {
  background: linear-gradient(135deg, var(--success), #6ed8ad);
  border-color: var(--success);
  color: #0f0f17;
}
.wish-item.done .card-title { text-decoration: line-through; color: var(--text-dim); }
.wish-priority {
  color: var(--accent);
  font-size: 12px;
  margin-right: 6px;
  letter-spacing: 0;
}
.wish-category-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(183, 107, 255, 0.14);
  border: 1px solid rgba(183, 107, 255, 0.35);
  border-radius: 999px;
  vertical-align: middle;
}
.wish-place {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-dim);
  word-break: keep-all;
}
.wish-open-link {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 4px;
  transition: all .15s;
}
.wish-open-link:hover {
  background: rgba(255,107,138,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* 위시 탭 — 카테고리 필터 칩 가로 스크롤 */
.wish-cat-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: -2px -4px 12px;
  padding: 6px 4px 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.wish-cat-strip::-webkit-scrollbar { display: none; }
.wish-cat-filter {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.wish-cat-filter:hover { color: var(--text); border-color: var(--text-dim); }
.wish-cat-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 위시 모달 — 카테고리 추천 칩 */
.wish-cat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 12px;
}
.wish-cat-suggest-chip {
  padding: 5px 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s ease;
}
.wish-cat-suggest-chip:hover {
  color: var(--text);
  border-color: var(--text-dim);
}
.wish-cat-suggest-chip.active {
  background: rgba(183, 107, 255, 0.2);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

/* 위시 모달 — 장소 미리보기 박스 */
.wish-place-preview {
  margin: 6px 0 12px;
  padding: 12px 14px;
  background: rgba(183, 107, 255, 0.08);
  border: 1px solid rgba(183, 107, 255, 0.25);
  border-radius: 12px;
}
.wish-place-preview.hidden { display: none; }
.wish-place-preview .wish-place-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.wish-place-preview .wish-place-addr {
  margin: 4px 0 0;
  font-size: 12px;
}
.wish-place-preview .wish-place-chip {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(183, 107, 255, 0.18);
  border-radius: 999px;
}

/* ====== 🎲 추억 한 장 (랜덤 회상 카드) ====== */
.throwback-wrap {
  margin: 0 0 14px;
}
.throwback-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(255,107,138,0.16), rgba(183,107,255,0.16));
  border: 1px solid rgba(255,107,138,0.3);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.throwback-btn:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255,107,138,0.28), rgba(183,107,255,0.28));
  transform: translateY(-1px);
}
.throwback-btn:active { transform: translateY(0); }
.throwback-btn.throwback-empty { opacity: 0.6; }
.throwback-icon { font-size: 15px; }

.throwback-card {
  margin-top: 10px;
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 8px 8px 12px;
  box-shadow: var(--shadow);
}
.throwback-card.hidden { display: none; }
.throwback-photo-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
}
#throwback-photo {
  display: block;
  width: 100%;
  height: 280px;
  object-fit: cover;
  transition: transform .35s ease;
}
.throwback-photo-wrap:hover #throwback-photo { transform: scale(1.03); }
.throwback-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 24px 14px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  color: #fff;
}
.throwback-date {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.throwback-hint {
  font-size: 11px;
  opacity: 0.85;
  background: rgba(255,255,255,0.15);
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.throwback-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: 0;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.throwback-shuffle {
  display: block;
  margin: 10px auto 0;
  padding: 8px 18px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.throwback-shuffle:hover {
  color: var(--text);
  border-color: var(--text-dim);
}
.throwback-fade {
  animation: throwback-fade-in .35s ease;
}
@keyframes throwback-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-card select {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
}
.modal-card select:focus { outline: none; border-color: var(--accent); }

/* ===== 캘린더 ===== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-header h3 { font-size: 17px; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 6px 0;
}
.cal-weekdays span:first-child { color: #ff8a8a; }
.cal-weekdays span:last-child { color: #8aaaff; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.cal-cell {
  min-height: 92px;
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 4px 5px 5px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  transition: background .15s, border-color .15s;
}
.cal-cell.muted { color: var(--muted); background: transparent; cursor: default; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.selected { background: var(--accent-soft); border-color: var(--accent); }
.cal-cell.has-content { background: color-mix(in srgb, var(--bg-card), var(--accent) 5%); }
.cal-cell.sunday .cal-day { color: #ff8a8a; }
.cal-cell.saturday .cal-day { color: #8aaaff; }

.cal-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}
.cal-day { font-size: 12px; font-weight: 600; }
.cal-badges {
  display: inline-flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 9px;
  line-height: 1;
}
.cal-badge {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 2px 4px;
  border-radius: 6px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.05);
  white-space: nowrap;
}
.cal-badge-call  { background: rgba(60,120,220,0.14); color: #4a78c4; }
.cal-badge-photo { background: rgba(220,80,140,0.14); color: #c45a85; }
.cal-badge-memo  { background: rgba(110,180,90,0.14); color: #6aa05a; }

.cal-anni, .cal-evt, .cal-story {
  font-size: 10.5px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  padding: 1px 4px;
  border-radius: 4px;
}
.cal-anni { background: rgba(255,180,80,0.16); color: #c0792b; font-weight: 600; }
.cal-evt-confirmed { background: rgba(150,90,220,0.14); color: #7a4cc0; }
.cal-evt-draft { background: rgba(150,90,220,0.08); color: #9888a8; font-style: italic; }
.cal-evt-more { opacity: 0.6; font-size: 9px; }
.cal-story { color: var(--text-dim); font-style: italic; }

@media (max-width: 480px) {
  .cal-cell { min-height: 78px; padding: 3px 3px 4px; }
  .cal-day { font-size: 11px; }
  .cal-badge { padding: 1px 3px; font-size: 8.5px; }
  .cal-anni, .cal-evt, .cal-story { font-size: 9.5px; padding: 0 3px; }
}

/* ===== 빈 상태 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .muted { font-size: 13px; }

/* ===== History 탭 (사진+일기 통합) ===== */
.head-actions { display: flex; gap: 8px; align-items: center; }
.btn-ghost-sm {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.btn-ghost-sm:hover { background: var(--border); }

#history-list { display: flex; flex-direction: column; gap: 18px; }
.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-date-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  row-gap: 4px;
}
.history-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}
.history-photos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  position: relative;
}
.history-photo-cell {
  position: relative;
  aspect-ratio: 1 / 1;
}
.history-photos img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .12s, opacity .2s, filter .2s;
}
.history-photos img:active { transform: scale(0.96); }

/* 업로드 중인 사진 — 살짝 어둡게 + 회전 스피너 */
.history-photo-cell.is-pending img {
  opacity: 0.55;
  filter: saturate(0.6);
}
.history-photo-cell .photo-spinner {
  position: absolute;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: photo-spin 0.8s linear infinite;
  pointer-events: none;
}
@keyframes photo-spin { to { transform: rotate(360deg); } }

/* 업로드 실패 — 빨간 ! 배지 + 흐릿 */
.history-photo-cell.is-failed img {
  opacity: 0.4;
  filter: grayscale(0.7);
}
.history-photo-cell .photo-failed-badge {
  position: absolute;
  right: 4px; top: 4px;
  width: 18px; height: 18px;
  background: #ff4d4f;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.history-photo-more {
  position: absolute;
  right: 0; bottom: 0;
  width: calc(25% - 3px);
  aspect-ratio: 1 / 1;
  background: rgba(0,0,0,0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  pointer-events: none;
}
.history-memory {
  cursor: pointer;
  padding: 10px 12px;
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  transition: background .15s;
}
.history-memory:hover { background: var(--border); }
.history-memory-title {
  font-weight: 700;
  margin: 0 0 4px;
  font-size: 15px;
}
.history-memory-content {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-write-btn {
  background: transparent;
  color: var(--accent);
  border: 1px dashed rgba(255,107,138,0.4);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.history-write-btn:hover { background: var(--accent-soft); }

/* 추억 모달 */
.memory-card { max-width: 480px; }
.memory-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 14px 0;
}
.memory-photos img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}
.memory-diary { display: flex; flex-direction: column; }

/* memory 모달 — 읽기 모드 vs 수정 모드 */
.memory-edit-toggle {
  position: absolute;
  top: 14px; right: 54px;       /* 닫기 X 옆 */
  padding: 5px 12px;
  background: rgba(255, 107, 138, 0.15);
  color: var(--accent);
  border: 1px solid rgba(255, 107, 138, 0.35);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
  z-index: 2;
}
.memory-edit-toggle:hover {
  background: rgba(255, 107, 138, 0.25);
  border-color: var(--accent);
}
#memory-modal.is-editing .memory-edit-toggle {
  background: rgba(94, 218, 155, 0.12);
  color: var(--success);
  border-color: rgba(94, 218, 155, 0.35);
}

/* 읽기 모드: input/textarea/select를 평문처럼 보이게 */
#memory-modal:not(.is-editing) .memory-diary input,
#memory-modal:not(.is-editing) .memory-diary textarea,
#memory-modal:not(.is-editing) .memory-diary select {
  background: transparent !important;
  border: 0 !important;
  padding: 4px 0 !important;
  cursor: default !important;
  resize: none !important;
  pointer-events: none;
  color: var(--text);
  outline: none !important;
}
#memory-modal:not(.is-editing) .memory-diary textarea {
  min-height: auto;
  height: auto;
}
#memory-modal:not(.is-editing) .memory-diary .muted-inline,
#memory-modal:not(.is-editing) .memory-diary label > span {
  display: none;
}
#memory-modal:not(.is-editing) .memory-diary label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 12px;
}
#memory-modal:not(.is-editing) .memory-diary input::placeholder,
#memory-modal:not(.is-editing) .memory-diary textarea::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* 캘린더에서 memory 표시 (포인터 강조) */
.memory-event { border-left: 3px solid var(--accent); }

/* 장소 라벨 — 날짜 옆에 인라인으로 붙음 */
.history-places {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* 지도 탭 */
#map-canvas {
  width: 100%;
  height: calc(100vh - 290px);
  min-height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b0b13;
}
.leaflet-container { background: #0b0b13 !important; font-family: inherit !important; }
.leaflet-popup-content-wrapper {
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 12px;
}
.leaflet-popup-tip { background: var(--bg-elev); }
.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: rgba(26, 26, 38, 0.92) !important;
  color: var(--text) !important;
  border-color: rgba(255,255,255,0.06) !important;
  backdrop-filter: blur(8px);
  width: 36px !important; height: 36px !important;
  line-height: 36px !important;
  font-size: 17px !important;
}
.leaflet-control-zoom a:hover { background: rgba(255,107,138,0.2) !important; color: var(--accent) !important; }
.leaflet-control-attribution { display: none !important; }

/* 지도 상단 요약 카드 */
.map-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255,107,138,0.08), rgba(183,107,255,0.08));
  border: 1px solid rgba(255,107,138,0.18);
  border-radius: var(--radius);
}
.map-summary-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}
.map-stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--text);
  font-size: 12px;
}
.map-stat b {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.map-stat-divider {
  width: 1px; height: 18px;
  background: var(--border);
}
.map-filter-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.map-filter-strip::-webkit-scrollbar { display: none; }
.map-filter {
  flex-shrink: 0;
  padding: 5px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.map-filter:hover { color: var(--text); border-color: var(--text-dim); }
.map-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 사진 마커 (조금 더 둥글고 부드러운 그림자) */
.photo-marker-wrap {
  background: transparent !important;
  border: 0 !important;
}
.photo-marker {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  overflow: visible;
  background: #fff;
  border: 2.5px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.photo-marker:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 22px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,107,138,0.4);
}
.photo-marker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 11px;
}
.photo-marker::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #fff;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
}
.photo-marker.is-cluster img { filter: brightness(0.55); }
.photo-marker-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  border-radius: 11px;
}

/* 위시 마커 (보라색 별, 갔다옴은 초록 ✓) */
.wish-marker-wrap {
  background: transparent !important;
  border: 0 !important;
}
.wish-marker {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b76bff, #8e3df5);
  border: 2.5px solid #fff;
  box-shadow: 0 4px 14px rgba(143, 51, 245, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.wish-marker:hover { transform: translateY(-2px) scale(1.08); }
.wish-marker.visited {
  background: linear-gradient(135deg, #5eda9b, #2eb87a);
  box-shadow: 0 4px 14px rgba(46, 184, 122, 0.5);
}
.wish-marker.is-cluster { width: 42px; height: 42px; }
.wish-marker-icon {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  z-index: 1;
}
.wish-marker::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fff;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
}
.wish-marker-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(183, 107, 255, 0.5);
  animation: wish-pulse 2.2s ease-out infinite;
  pointer-events: none;
}
.wish-marker.visited .wish-marker-pulse { border-color: rgba(94, 218, 155, 0.5); }
@keyframes wish-pulse {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.7); opacity: 0; }
}
.wish-marker-count {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  background: #fff;
  color: var(--accent-2);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--accent-2);
}

/* markercluster 기본 클래스가 같이 붙어도 우리 스타일 유지 */
.leaflet-marker-icon.photo-marker-wrap,
.leaflet-marker-icon.wish-marker-wrap { background: transparent !important; }
.marker-cluster, .marker-cluster div {
  background: transparent !important;
  box-shadow: none !important;
}
.marker-cluster span { display: none; }

/* 사진 마커 hover/long-tap tooltip — 날짜 빠른 확인 */
.leaflet-tooltip.photo-tooltip {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}
.leaflet-tooltip.photo-tooltip::before {
  border-top-color: rgba(0,0,0,0.85);
}

/* 위시 마커 클릭 popup */
.leaflet-popup.wish-popup .leaflet-popup-content-wrapper {
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 14px;
  padding: 0;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.leaflet-popup.wish-popup .leaflet-popup-content {
  margin: 0;
  padding: 14px;
  font-size: inherit;
  line-height: 1.4;
}
.leaflet-popup.wish-popup .leaflet-popup-tip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top: 0;
  border-left: 0;
}
.wish-popup-card { display: flex; flex-direction: column; gap: 6px; }
.wish-popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.wish-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.wish-popup-cat {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-2);
  background: rgba(183, 107, 255, 0.18);
  border: 1px solid rgba(183, 107, 255, 0.4);
  border-radius: 999px;
}
.wish-popup-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: -2px;
}
.wish-popup-addr {
  font-size: 12px;
  color: var(--text-dim);
  word-break: keep-all;
}
.wish-popup-memo {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: 8px;
}
.wish-popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.wish-popup-actions button {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
  white-space: nowrap;
}
.wish-popup-actions button:hover {
  background: rgba(255,107,138,0.1);
  border-color: var(--accent);
  color: var(--accent);
}
.wish-popup-check.is-done {
  background: rgba(94, 218, 155, 0.18);
  border-color: var(--success);
  color: var(--success);
}

/* 사진 뷰어 — 상단 메타 오버레이 (날짜/장소/카운터) */
.photo-meta {
  position: absolute;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  color: #fff;
  z-index: 2;
  max-width: 80%;
  pointer-events: none;
  text-align: center;
}
#photo-meta-date { font-size: 13px; font-weight: 600; }
#photo-meta-place { font-size: 11px; opacity: 0.85; }
#photo-meta-counter { font-size: 10px; opacity: 0.65; letter-spacing: 0.8px; margin-top: 1px; }

/* 사진 뷰어 하단 바 — 4개 액션 버튼 가로 정렬 (모바일에서도 fit) */
.photo-viewer-bar {
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}
.photo-viewer-bar::-webkit-scrollbar { display: none; }
.photo-viewer-bar .photo-action {
  flex-shrink: 0;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 12px;
  border-radius: 999px;
  width: auto;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all .12s ease;
}
.photo-viewer-bar .photo-action:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.3);
}
.photo-viewer-bar .photo-action.btn-danger {
  background: rgba(255, 94, 94, 0.15);
  color: #ff8a8a;
  border-color: rgba(255, 94, 94, 0.4);
}
.photo-viewer-bar .photo-action.btn-danger:hover {
  background: rgba(255, 94, 94, 0.3);
  color: #fff;
}
.photo-mapview.hidden { display: none; }

/* ===== 교환일기 ===== */
.diary-compose {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diary-compose textarea,
.diary-compose select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  resize: vertical;
  width: 100%;
}
.diary-compose textarea:focus,
.diary-compose select:focus { outline: none; border-color: var(--accent); }

.diary-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.diary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
}
.diary-item.me { border-left: 3px solid var(--accent); }
.diary-item.partner { border-left: 3px solid var(--accent-2); }
.diary-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.diary-author { font-weight: 700; color: var(--text); }
.diary-content { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

/* ===== 하단 탭 ===== */
.bottom-tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  background: rgba(20, 20, 30, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 40;
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  transition: color .15s;
}
.tab-icon { font-size: 20px; }
.tab-label { font-size: 11px; letter-spacing: 0.5px; }
.tab-btn.active { color: var(--accent); }
.tab-btn.active .tab-icon { transform: scale(1.05); }

/* ===== 모달 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;            /* Leaflet 컨트롤(z:1000) 보다 위 */
  padding: 20px;
  animation: fadeIn .2s ease;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2, .modal-card h3 { margin-bottom: 12px; }
.modal-card label {
  display: block;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.modal-card input,
.modal-card textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
}
.modal-card input:focus,
.modal-card textarea:focus { outline: none; border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions button { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

/* 버튼 */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  width: 100%;
  transition: transform .1s, opacity .15s;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.92; }
.btn-ghost {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
.btn-ghost:hover { background: var(--border); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
.btn-danger:hover { background: rgba(255, 94, 94, 0.12); }

/* 사진 뷰어 */
#photo-viewer {
  background: rgba(0,0,0,0.95);
  padding: 0;
}
#photo-viewer img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  transform-origin: center center;
  transition: transform 0.22s ease;
  will-change: transform;
  touch-action: none;            /* 브라우저 기본 핀치 줌/스크롤 막기 */
  -webkit-user-drag: none;
  user-select: none;
  cursor: grab;
}
#photo-viewer img:active { cursor: grabbing; }
.photo-close {
  position: absolute;
  top: calc(20px + var(--safe-top));
  right: 20px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
}
.photo-delete {
  position: absolute;
  bottom: calc(30px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  min-width: 140px;
}

/* 반응형: 데스크탑 */
@media (min-width: 768px) {
  body { font-size: 16px; }
  main { padding: 30px 30px 60px; }
  .dday-hero h2 { font-size: 64px; }
  .album-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ========== 월별 History 레이아웃 ========== */
.history-month-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 10px 2px 12px;
  margin: -4px -4px 4px;
  position: sticky;
  /* 헤더(56px + safe-top) 바로 아래에 붙어서 화면 가리지 않게 */
  top: calc(56px + var(--safe-top));
  background: var(--bg);
  z-index: 5;
  scroll-snap-type: x proximity;
  box-shadow: 0 4px 12px -8px rgba(0,0,0,0.6);
}
.history-month-strip::-webkit-scrollbar { display: none; }
.month-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  scroll-snap-align: center;
  white-space: nowrap;
}
.month-chip .month-chip-count {
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.month-chip:active { transform: scale(0.96); }
.month-chip.active {
  background: linear-gradient(135deg, rgba(255,107,138,0.25), rgba(183,107,255,0.25));
  border-color: rgba(255,107,138,0.45);
  color: var(--text);
}
.month-chip.active .month-chip-count {
  background: var(--accent);
  color: #fff;
}

.history-month {
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* 헤더(56) + strip(약 60) + 여백(8) = 124. 안전하게 130. */
  scroll-margin-top: calc(130px + var(--safe-top));
}
.history-month-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 4px 0;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}
.history-month:first-of-type .history-month-header {
  border-top: none;
  padding-top: 0;
}
.history-month-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.history-month-meta {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

/* 8번째 셀 위에 +N 엠보스 (사진은 그대로 보이고 그 위에 반투명 오버레이) */
.history-photo-cell.is-overflow .photo-more-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border: none;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  border-radius: 8px;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.history-photo-cell.is-overflow .photo-more-overlay:active {
  transform: scale(0.96);
  background: rgba(0,0,0,0.7);
}

/* 펼쳤을 때 접기 버튼 */
.history-collapse-btn {
  margin-left: auto;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.history-collapse-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* ========== 통화 텍스트 (익시오 분석) ========== */
.call-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  transition: all .15s ease;
}
.call-drop-zone:hover, .call-drop-zone.is-drag {
  border-color: var(--accent);
  background: rgba(255,107,138,0.08);
}
.call-drop-icon { font-size: 28px; }
.call-drop-text { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.call-drop-name { font-size: 12px; color: var(--accent); font-weight: 600; word-break: break-all; text-align: center; }
.call-meta-preview { color: var(--accent-2) !important; }

/* memory 모달 안 통화 섹션 */
.memory-calls { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.memory-calls:empty { display: none; }
.call-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.call-card.is-pending { border-style: dashed; opacity: 0.85; }
.call-card.is-failed { border-color: var(--danger); }
.call-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.call-card-icon { font-size: 14px; }
.call-card-status {
  font-size: 12px;
  color: var(--text-dim);
}
.call-card-summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 0;
}
.call-card-long {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}
.call-card-emotion {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 8px;
  background: rgba(183,107,255,0.08);
  border-radius: 6px;
  border-left: 2px solid var(--accent-2);
}
.call-card-promises {
  font-size: 12px;
}
.call-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.call-card-promises ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.55;
}
.call-card-details {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 8px;
  background: var(--bg-elev);
  border-radius: 6px;
}
.call-card-kw {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.call-kw {
  padding: 2px 8px;
  font-size: 10px;
  background: rgba(255,107,138,0.12);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 600;
}
.call-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
}
.call-card-delete:hover { color: var(--danger); }

/* 캘린더 초안 일정 (통화에서 추출) */
.event-draft {
  border-style: dashed !important;
  border-color: var(--accent-2) !important;
  background: rgba(183,107,255,0.05) !important;
}
.event-source-tag {
  margin-left: 8px;
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(183,107,255,0.18);
  color: var(--accent-2);
  border-radius: 999px;
  font-weight: 700;
}
.event-confirm, .event-reject {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s ease;
  margin-left: 4px;
}
.event-confirm { color: var(--success); border-color: rgba(94,218,155,0.4); }
.event-confirm:hover { background: var(--success); color: #0f0f17; border-color: var(--success); }
.event-reject:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ========== 통합 검색 모달 ========== */
.search-card {
  max-width: 560px;
  width: 92%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
#search-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
}
#search-input:focus { outline: none; border-color: var(--accent); }
.search-results {
  flex: 1;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.search-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.search-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 2px;
}
.search-hit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all .12s ease;
}
.search-hit:hover {
  border-color: var(--accent);
  background: rgba(255,107,138,0.05);
}
.search-hit-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.search-hit-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.search-hit-sub {
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-word;
}
.search-hit mark, .search-hit-title mark, .search-hit-sub mark {
  background: rgba(255,107,138,0.3);
  color: var(--text);
  padding: 0 2px;
  border-radius: 3px;
}
.search-photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 6px;
  scrollbar-width: none;
}
.search-photo-strip::-webkit-scrollbar { display: none; }
.search-photo {
  flex-shrink: 0;
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  padding: 0;
}
.search-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.search-photo-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px 6px 4px;
  font-size: 10px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  line-height: 1.2;
}

/* ===== 주간 관계 인사이트 ===== */
.insight-hint { margin: 0 0 12px; font-size: 12px; }
.insight-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.insight-card.is-highlight {
  border-color: color-mix(in srgb, var(--accent), transparent 50%);
  box-shadow: 0 4px 18px -10px color-mix(in srgb, var(--accent), transparent 30%);
}
.insight-card.flash { animation: insightFlash 1.2s ease; }
@keyframes insightFlash {
  0%   { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 60%); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.insight-card-head {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: background .12s;
}
.insight-card-head:hover { background: color-mix(in srgb, var(--bg-card), var(--accent) 4%); }

.insight-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.insight-card-week  { font-weight: 600; font-size: 14px; color: var(--text); }
.insight-card-count { font-size: 11px; color: var(--text-dim); }
.insight-card-preview {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-top: 2px;
}
.insight-card-toggle {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform .2s;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}
.insight-card.expanded .insight-card-toggle { transform: translateY(-50%) rotate(180deg); }

.insight-card-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px dashed var(--border);
}
.insight-card.expanded .insight-card-body { display: block; }

.insight-section {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border-left: 3px solid transparent;
}
.insight-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 6px;
}
.insight-section-icon { font-size: 14px; }
.insight-section-body { font-size: 13px; color: var(--text); line-height: 1.55; }
.insight-section-body p { margin: 4px 0; }
.insight-section-body ul { margin: 4px 0 4px 18px; padding: 0; }
.insight-section-body li { margin: 3px 0; }

.insight-tone-topic    { border-left-color: #6aa0ff; }
.insight-tone-want     { border-left-color: #b870e0; }
.insight-tone-good     { border-left-color: #6cc59a; }
.insight-tone-friction { border-left-color: #d99270; }
.insight-tone-improve  { border-left-color: #d4b96a; }

/* ===== 추억 모달 — 본문 스크롤/동적 높이 (2026-05-18) ===== */
/* memory-card는 modal-card max-height:90vh를 유지하면서 본문 영역에서 스크롤이 일어나야 함.
   memory-body가 flex로 자라고 내부 textarea는 입력 양에 따라 자동 확장 (JS의 autoSizeMemoryTextarea와 협업). */
.memory-card {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.memory-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;        /* 스크롤바 폭 보정 */
  min-height: 0;             /* flex 자식이 부모 max-height를 따라 줄어들 수 있도록 */
}
.memory-actions {
  flex: 0 0 auto;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  bottom: 0;
}
/* 일기 textarea — 편집 모드에서 자동 확장 */
.memory-diary textarea {
  resize: vertical;
  min-height: 100px;
  max-height: 60vh;
  line-height: 1.55;
  overflow-y: auto;
}

/* ===== 음성 요약 토글 카드 (memory-modal 안, 일기 아래) ===== */
.memory-story {
  margin-top: 18px;
  padding: 0;
  background: rgba(255, 107, 138, 0.06);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 70%);
  border-radius: 14px;
  overflow: hidden;
}
.memory-story:empty { display: none; }
.story-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.story-toggle:hover { background: rgba(255,255,255,0.03); }
.story-toggle-icon { font-size: 16px; }
.story-toggle-label { flex: 1; }
.story-toggle-caret {
  transition: transform .2s ease;
  color: var(--text-dim);
}
.memory-story.is-open .story-toggle-caret { transform: rotate(180deg); }
.story-headline {
  padding: 0 14px 12px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.story-headline.muted { color: var(--muted); font-size: 12.5px; }
.story-body {
  display: none;
  padding: 4px 14px 14px;
  border-top: 1px dashed color-mix(in srgb, var(--accent), transparent 80%);
}
.memory-story.is-open .story-body { display: block; }
.story-long {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 8px;
}
.story-emotion, .story-highlights {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}
.story-kw {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 8px;
}
.story-details { margin-top: 10px; }
.story-details > summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 4px 0;
  list-style: none;
}
.story-details > summary::-webkit-details-marker { display: none; }
.story-details > summary::before { content: '▸ '; color: var(--text-dim); }
.story-details[open] > summary::before { content: '▾ '; }
.story-calls { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* call-event — 캘린더 일정 리스트의 '통화/음성 요약' 카드 */
.call-event {
  border-left: 3px solid color-mix(in srgb, var(--accent), transparent 30%);
  background: rgba(255, 107, 138, 0.05);
}

/* ===== 영상 탭 ===== */
.video-status { font-size: 12.5px; margin: 6px 0; min-height: 16px; }
.video-list { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }
.video-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.video-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.video-day-date { font-weight: 600; font-size: 14px; }
.video-day-meta { font-size: 11.5px; color: var(--text-dim); }
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.video-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}
.video-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.video-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.video-dur, .video-size {
  position: absolute;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}
.video-dur { bottom: 6px; right: 6px; }
.video-size { top: 6px; left: 6px; opacity: 0.85; }

/* 영상 뷰어 — 사진 뷰어와 비슷한 풀스크린 */
#video-viewer {
  background: rgba(0,0,0,0.92);
  padding: 0;
  align-items: center;
}
.video-viewer-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}
#video-full {
  width: 100%;
  max-height: calc(100vh - 100px);
  background: #000;
  border-radius: 8px;
}
.video-viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  color: #ddd;
}

/* 사진 페이지네이션 — 미로드 달 placeholder */
.history-month-placeholder {
  padding: 14px 12px 18px;
  text-align: center;
}
.history-load-month {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.history-load-month:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.history-load-month:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ===== 설정 — 알림 섹션 ===== */
.set-notify-section {
  margin-top: 18px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.set-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 !important;
  cursor: pointer;
}
.set-toggle-row > span:first-child {
  flex: 1;
  font-size: 14px;
  color: var(--text);
}
.set-toggle-row .muted-inline {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.set-toggle-row input[type="checkbox"] {
  width: 44px;
  height: 24px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background .15s;
  cursor: pointer;
  flex-shrink: 0;
}
.set-toggle-row input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.set-toggle-row input[type="checkbox"]:checked {
  background: var(--accent);
}
.set-toggle-row input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}
.set-toggle-row input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.set-notify-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.set-notify-actions .btn-ghost {
  font-size: 12.5px;
  padding: 6px 12px;
}
