/* ============ Our Story — 가족 웹앨범 (라이트 테마) ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e6e8ee;
  --line2: #f0f1f5;
  --fg: #1f2430;
  --muted: #7a8194;
  --accent: #3f83f8;
  --accent-soft: #eaf1fe;
  --danger: #e15b5b;
  --ok: #35a06e;
  --warn: #d99a1b;
  --sidebar-w: 224px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 24, 40, .06);
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.spacer { flex: 1; }
svg.ico, .ico svg { width: 15px; height: 15px; vertical-align: -2px; }
.empty-note { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- 로그인 ---------- */
#login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef3fb 0%, var(--bg) 70%);
}
#login-form {
  width: 330px; padding: 44px 34px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; text-align: center;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 40px rgba(20,24,40,.08);
}
.login-logo { font-size: 40px; }
#login-form h1 { font-family: 'Nanum Pen Script', cursive; font-size: 40px; font-weight: 400; }
.login-sub { color: var(--muted); margin-bottom: 8px; }
#login-form input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); outline: none;
}
#login-form input:focus { border-color: var(--accent); background: #fff; }
#login-form button {
  padding: 12px; border-radius: 10px; background: var(--accent);
  color: #fff; font-weight: 600; margin-top: 4px;
}
#login-error { color: var(--danger); min-height: 18px; font-size: 13px; }

/* ---------- 레이아웃 ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 14px 16px;
}
.brand { padding: 0 10px 22px; }
.brand-sub { font-family: 'Nanum Pen Script', cursive; font-size: 17px; color: var(--muted); }
.brand-main { font-family: 'Nanum Pen Script', cursive; font-size: 30px; line-height: 1.15; }
.brand-main .heart { font-size: 18px; margin-left: 3px; }

#sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#sidebar nav a {
  padding: 10px 12px; border-radius: 10px; color: #55607a;
  display: flex; gap: 12px; align-items: center; font-weight: 500;
}
#sidebar nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
#sidebar nav a:hover { background: var(--line2); color: var(--fg); }
#sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }

.sidebar-bottom { display: flex; flex-direction: column; gap: 10px; }
.btn-primary {
  background: var(--accent); color: #fff; padding: 11px; border-radius: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { color: var(--muted); padding: 7px; border-radius: 8px; font-size: 13px; }
.btn-ghost:hover { background: var(--line2); color: var(--fg); }

#storage-widget {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
#storage-widget .st-label { font-size: 12px; color: var(--muted); }
#storage-widget .st-val { font-size: 13px; font-weight: 600; margin: 3px 0 8px; }
#storage-widget .st-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#storage-widget .st-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 28px 0;
}
#btn-hidden { white-space: nowrap; }
.search-box {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 8px 16px; width: 300px; color: var(--muted);
}
.search-box svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-box input { border: none; outline: none; background: none; flex: 1; min-width: 0; color: var(--fg); }
#view { flex: 1; padding: 18px 28px 80px; min-width: 0; }

.view-title { font-size: 21px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-title .count { font-size: 14px; color: var(--muted); font-weight: 400; }

/* ---------- 공용 버튼/입력 ---------- */
.btn {
  padding: 7px 14px; border-radius: 9px; background: var(--surface);
  border: 1px solid var(--line); font-size: 13px; box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.icon { padding: 7px 11px; font-size: 15px; line-height: 1; }
.btn:disabled { opacity: .5; cursor: default; }
.inp {
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); outline: none; font-size: 13px;
}
.inp:focus { border-color: var(--accent); }

/* 세그먼트 토글 (월/연도, 전체/사진/영상) */
.seg { display: flex; gap: 4px; background: var(--line2); border-radius: 10px; padding: 3px; }
.seg-btn { padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.seg-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- 필터 바 ---------- */
.filterbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow);
}
.filterbar .inp { background: var(--bg); }
.filterbar .inp:focus { background: #fff; }
.filterbar .sep { width: 1px; height: 22px; background: var(--line); }

/* 글자 자체가 체크박스인 토글 */
.toggle-chip {
  padding: 7px 15px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 13px; user-select: none;
}
.toggle-chip:hover { border-color: var(--accent); color: var(--accent); }
.toggle-chip.active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

/* ---------- 그리드 ---------- */
.grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.cell {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--line2); cursor: pointer; user-select: none;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell:hover img { filter: brightness(1.06); }
/* 셀 오버레이 글자는 그리드 크기에 비례해 확대 (--cs: applyGridSizeTo에서 설정) */
.cell .badge-video {
  position: absolute; right: 7px; top: 7px; background: rgba(15,18,26,.7);
  color: #fff; font-size: calc(11px * var(--cs, 1)); padding: 2px 8px; border-radius: 12px; z-index: 2;
}
.cell .cell-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: calc(34px * var(--cs, 1)); color: rgba(255,255,255,.72); text-shadow: 0 2px 12px rgba(0,0,0,.5);
  pointer-events: none; z-index: 1;
}
.cell .cell-desc {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 26px 9px 8px; font-size: calc(13px * var(--cs, 1)); font-weight: 700; color: #fff; text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,.55) 40%, rgba(0,0,0,.92));
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell .badge-fav {
  position: absolute; right: 7px; bottom: 6px; font-size: calc(14px * var(--cs, 1));
  text-shadow: 0 0 4px rgba(0,0,0,.6); z-index: 3;
}
/* 숨긴 항목: 배지 대신 살짝 어둡게 (숨김 보기 켰을 때) */
.cell.hid img { filter: brightness(.45) saturate(.55); }
.cell.hid:hover img { filter: brightness(.62) saturate(.7); }
/* 액자 테두리 우선도: 은색 < 대표(A컷) < 금색(따봉 둘 다) — 그리드 크기(--cs)에 비례해 두께도 커짐 */
.cell.pick::after {
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  border: calc(4px * var(--cs, 1)) solid #f2b01e; border-radius: 10px;
}
.cell.like-silver::before {
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  border: calc(4px * var(--cs, 1)) solid #c7ccd6; border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}
.cell.like-gold::before {
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  border: calc(4px * var(--cs, 1)) solid #ffd23f; border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.65), 0 0 10px rgba(255,210,63,.55);
}
/* 우선도 낮은 테두리는 숨김: 대표+은색이면 대표만, 대표+금색이면 금색만 */
.cell.pick.like-silver::before { display: none; }
.cell.pick.like-gold::after { display: none; }
.cell .badge-like {
  position: absolute; left: 7px; bottom: 6px; font-size: calc(14px * var(--cs, 1));
  text-shadow: 0 0 4px rgba(0,0,0,.6); z-index: 3;
}
.tl-thumb.pick::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  border: 2.5px solid #f2b01e; border-radius: 8px;
}
.tl-thumb { position: relative; }

/* 최근 추가된 항목: 행 전체가 클릭 대상 */
.recent-row { cursor: pointer; border-radius: 10px; }
.recent-row:hover { background: var(--line2); }
.recent-row .tl-date { width: 120px; }
.cell .badge-status {
  position: absolute; left: 7px; bottom: 32px; font-size: 10px; padding: 2px 7px;
  border-radius: 8px; background: rgba(15,18,26,.7); color: #ffd66b; z-index: 3;
}
.cell .badge-comment {
  position: absolute; left: 7px; top: 7px; font-size: calc(11px * var(--cs, 1)); padding: 2px 8px;
  border-radius: 12px; background: rgba(15,18,26,.7); color: #fff; z-index: 3;
}
.grid.has-sel .badge-comment, .cell:hover .badge-comment { left: 34px; } /* 선택 체크와 겹침 방지 */
.cell .ck {
  position: absolute; left: 7px; top: 7px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.9); background: rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: transparent;
  opacity: 0; transition: opacity .12s;
}
.cell:hover .ck, .grid.has-sel .ck { opacity: 1; }
.cell.sel .ck { background: var(--accent); border-color: var(--accent); color: #fff; opacity: 1; }
.cell.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.cell.sel img { filter: brightness(.8); }
.grid-empty { color: var(--muted); text-align: center; padding: 60px 0; grid-column: 1/-1; }
.grid-sentinel { grid-column: 1/-1; height: 10px; }
.date-sep { grid-column: 1/-1; padding: 16px 2px 4px; font-weight: 600; color: var(--muted); font-size: 13px; }
.date-sep.selectable { user-select: none; }
.date-sep .ds-label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 3px 10px 3px 4px; border-radius: 16px;
}
.date-sep .ds-ck {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c9cedb;
  background: var(--surface); color: transparent; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
}
.date-sep .ds-label:hover { color: var(--fg); background: var(--line2); }
.date-sep .ds-label:hover .ds-ck { border-color: var(--accent); }
.date-sep.all-sel .ds-label { color: var(--accent); }
.date-sep.all-sel .ds-ck { background: var(--accent); border-color: var(--accent); color: #fff; }
.date-sep .ds-title { color: var(--accent); font-weight: 700; margin-left: 8px; }

/* ---------- 선택 액션바 ---------- */
#actionbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 10px 36px rgba(20,24,40,.16); padding: 10px 14px;
  display: flex; gap: 8px; align-items: center; z-index: 900; flex-wrap: wrap;
  max-width: calc(100vw - 40px);
}
#actionbar .sel-count { font-weight: 700; color: var(--accent); margin-right: 4px; white-space: nowrap; }

/* ---------- 우클릭 컨텍스트 메뉴 ---------- */
#ctx-menu {
  position: fixed; z-index: 980; min-width: 170px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(20,24,40,.22); padding: 6px;
  display: flex; flex-direction: column;
}
#ctx-menu button { text-align: left; padding: 9px 13px; border-radius: 8px; font-size: 13px; }
#ctx-menu button:hover { background: var(--accent-soft); color: var(--accent); }
#ctx-menu button.danger { color: var(--danger); }
#ctx-menu button.danger:hover { background: #fdecec; color: var(--danger); }

/* ---------- 플로팅 선택창 (장소/태그 자동완성) ---------- */
#picker {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  width: 320px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 14px 44px rgba(20,24,40,.22); padding: 14px; z-index: 985;
}
#picker.at-point { transform: none; bottom: auto; } /* 우클릭 메뉴 근처에 좌표 배치 */
#picker.centered { top: 50%; bottom: auto; transform: translate(-50%, -50%); } /* 화면 중앙 */

/* 플로팅 입력상자 (설명 입력) */
#inputbox {
  position: fixed; z-index: 985; width: 320px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 14px 44px rgba(20,24,40,.22); padding: 14px;
}
#inputbox input { width: 100%; margin-bottom: 10px; }
#inputbox .ib-actions { display: flex; gap: 8px; align-items: center; }

/* 공유 링크 상자 */
#sharebox {
  position: fixed; z-index: 985; width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 14px 44px rgba(20,24,40,.22); padding: 14px;
}
#sharebox .share-url {
  display: block; width: 100%; text-align: left; word-break: break-all;
  background: var(--bg); border: 1px dashed #c3cbdd; border-radius: 9px;
  padding: 10px 12px; margin: 4px 0 8px; font-size: 13px; color: var(--accent);
}
#sharebox .share-url:hover { border-color: var(--accent); background: var(--accent-soft); }
#picker .pk-head { font-weight: 700; font-size: 13.5px; margin-bottom: 9px; }
#picker .pk-input { width: 100%; margin-bottom: 8px; }
#picker .pk-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
#picker .pk-item {
  text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  display: flex; justify-content: space-between; gap: 8px;
}
#picker .pk-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#picker .pk-item:hover { background: var(--accent-soft); color: var(--accent); }
#picker .pk-item .cnt { color: var(--muted); flex-shrink: 0; }
#picker .pk-item.pk-clear { color: var(--danger); }
#picker .pk-empty, #picker .pk-hint { color: var(--muted); font-size: 12px; padding: 6px 2px 0; }

/* ---------- 상세보기 모달 (라이트박스) ---------- */
#lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(12,14,20,.95); display: flex; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; padding: 20px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: calc(100vh - 40px); object-fit: contain; border-radius: 4px; }
.lb-close, .lb-prev, .lb-next, .lb-info-toggle {
  position: absolute; z-index: 1010; color: #fff; background: rgba(40,45,58,.7);
  border-radius: 50%; width: 44px; height: 44px; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover, .lb-info-toggle:hover { background: rgba(70,78,98,.9); }
.lb-close { top: 16px; left: 16px; }
.lb-info-toggle { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); font-size: 30px; }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); font-size: 30px; }
#lightbox.panel-open .lb-next, #lightbox.panel-open .lb-info-toggle { right: 356px; }

.lb-panel {
  width: 340px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--line);
  padding: 20px; overflow-y: auto; display: none; color: var(--fg);
}
#lightbox.panel-open .lb-panel { display: block; }
.lb-panel h3 { font-size: 13px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.lb-panel h3:first-child { margin-top: 0; }
.lb-filename { font-weight: 600; word-break: break-all; margin-bottom: 4px; }
.lb-meta-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.lb-meta-table td { padding: 4px 0; vertical-align: top; }
.lb-meta-table td:first-child { color: var(--muted); width: 74px; }
.lb-row { display: flex; gap: 6px; margin-top: 6px; }
.lb-row .inp { flex: 1; min-width: 0; }
.lb-actions { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.src-manual { color: var(--warn); font-size: 11px; margin-left: 4px; }

/* 확대보기 하단 댓글 */
.lb-comments {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 1006;
  width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#lightbox.panel-open .lb-comments { width: min(560px, calc(100vw - 380px)); left: calc(50% - 170px); }
.lbc-bar { display: flex; gap: 8px; }
.lbc-head {
  background: rgba(30,34,44,.85); color: #fff; border-radius: 20px;
  padding: 8px 18px; font-size: 13px; font-weight: 600;
}
.lbc-head:hover { background: rgba(60,68,88,.9); }
.lbc-like {
  background: rgba(30,34,44,.85); color: #fff; border-radius: 20px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; max-width: 220px; overflow: hidden;
}
.lbc-like span { color: #b7c8ff; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.lbc-like:hover { background: rgba(60,68,88,.9); }
.lbc-like.mine { background: rgba(91,141,239,.35); box-shadow: inset 0 0 0 1px rgba(91,141,239,.7); }
.lbc-like.all { background: rgba(255,210,63,.28); box-shadow: inset 0 0 0 1px rgba(255,210,63,.8); }
.lbc-like.all span { color: #ffd23f; }
.lbc-body {
  width: 100%; background: rgba(20,24,32,.94); border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px; padding: 10px 14px; max-height: 34vh;
  display: flex; flex-direction: column;
}
.lbc-list { overflow-y: auto; flex: 1; min-height: 0; }
.lbc-item {
  color: #e8ebf2; font-size: 13px; padding: 7px 0; display: flex; gap: 8px;
  align-items: baseline; border-bottom: 1px solid rgba(255,255,255,.07);
}
.lbc-item:last-child { border-bottom: none; }
.lbc-author { font-weight: 700; color: #9db8f0; flex-shrink: 0; }
.lbc-text { flex: 1; word-break: break-word; }
.lbc-time { color: #8b93a7; font-size: 11px; flex-shrink: 0; }
.lbc-del { color: #8b93a7; font-size: 11px; flex-shrink: 0; }
.lbc-del:hover { color: var(--danger); }
.lbc-empty { color: #8b93a7; padding: 8px 0; font-size: 13px; text-align: center; }
.lbc-input { display: flex; gap: 6px; margin-top: 9px; }
.lbc-input .inp {
  flex: 1; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff;
}
.lbc-input .inp::placeholder { color: #8b93a7; }

.lbc-new {
  color: #ff7b7b; font-size: 10.5px; font-weight: 800; margin-left: 3px;
  vertical-align: 1px;
}

/* 사이드바 댓글알림 배지 */
.noti-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  font-weight: 700; padding: 1px 7px; border-radius: 10px;
}

/* 댓글알림 목록 */
.noti-list { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.noti-item {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px 10px 10px; box-shadow: var(--shadow);
}
.noti-item:hover { border-color: var(--accent); }
.noti-item img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 9px; flex-shrink: 0;
  background: var(--line2);
}
.noti-body { flex: 1; min-width: 0; font-size: 14px; }
.noti-author { font-weight: 700; }
.noti-sep { color: var(--muted); margin: 0 2px; }
.noti-text { word-break: break-word; }
.noti-time { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.noti-new {
  color: #fff; background: var(--danger); font-size: 11px; font-weight: 800;
  padding: 2px 9px; border-radius: 10px; flex-shrink: 0;
}

/* 태그 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg); border: 1px solid var(--line); padding: 4px 11px;
  border-radius: 20px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center;
}
.chip button { color: var(--muted); font-size: 11px; }
.chip button:hover { color: var(--danger); }
.chip.link:hover { border-color: var(--accent); color: var(--accent); cursor: pointer; }
.chip .cnt { color: var(--muted); }

/* ---------- 홈: 달력 ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-head h2 { font-size: 21px; margin-right: 8px; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.cal-dow {
  text-align: center; color: var(--muted); font-size: 12.5px; padding: 11px 0;
  border-bottom: 1px solid var(--line); font-weight: 500;
}
.cal-dow.sun { color: #e08585; }
.cal-day {
  position: relative; min-height: 134px; padding: 8px 9px 7px; font-size: 12px;
  border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2);
  display: flex; flex-direction: column; overflow: hidden;
}
.cal-day:nth-child(7n+1) { border-right: 1px solid var(--line2); }
.cal-day .dnum { font-weight: 600; font-size: 13px; }
.cal-day.sun .dnum { color: #e05a5a; }
.cal-day.dim .dnum { color: #c3c8d4; font-weight: 400; }
.cal-day.today .dnum {
  color: #fff; background: var(--accent); width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-day.has-media { cursor: pointer; }
.cal-day.has-media:hover { background: #fafbfe; }
.cal-day.selected { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

/* 달력 셀: 썸네일이 칸을 가득 채움 */
.cal-day .day-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
}
.cal-day.has-media:hover .day-bg { filter: brightness(1.08); }
.cal-day .dnum { position: relative; z-index: 2; }
.cal-day.has-media .dnum { color: #fff; text-shadow: 0 1px 5px rgba(0,0,0,.85); }
.cal-day.has-media.sun .dnum { color: #ffb3b3; }
.cal-day.has-media.today .dnum { color: #fff; text-shadow: none; }

.cal-day .day-meta {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 20px 8px 6px; display: flex; flex-direction: column; gap: 1px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); overflow: hidden;
}
.cal-day .day-title {
  font-size: 11.5px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.cal-day .day-count {
  font-size: 11px; color: #e3e6ee; display: flex; align-items: center; gap: 4px;
}

/* 연도 보기 */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.year-cell {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; text-align: center; box-shadow: var(--shadow); color: var(--muted);
}
.year-cell.has-media { cursor: pointer; color: var(--fg); }
.year-cell.has-media:hover { border-color: var(--accent); }
.year-cell .ym-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.year-cell .ym-cnt { font-size: 12.5px; color: var(--muted); }

/* ---------- 타임라인 (날짜별 행) ---------- */
.tl-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; margin-top: 20px; box-shadow: var(--shadow);
}
.tl-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.tl-head h3 { font-size: 16px; flex: 1; }
.tl-row {
  display: flex; gap: 18px; padding: 15px 0; border-bottom: 1px solid var(--line2);
  position: relative;
}
.tl-row:last-child { border-bottom: none; }
.tl-date {
  width: 84px; flex-shrink: 0; font-weight: 600; font-size: 13.5px; padding-top: 4px;
  display: flex; align-items: flex-start; gap: 9px;
}
.tl-date small { color: var(--muted); font-weight: 400; }
.tl-date .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  margin-top: 5px; flex-shrink: 0; box-shadow: 0 0 0 3px var(--accent-soft);
}
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 700; font-size: 14.5px; }
.tl-title:empty { display: none; }
.tl-counts { color: var(--muted); font-size: 12.5px; margin: 3px 0 9px; display: flex; align-items: center; gap: 5px; }
.tl-thumbs { display: flex; gap: 7px; flex-wrap: wrap; }
.tl-thumb {
  position: relative; width: 86px; height: 62px; border-radius: 8px; overflow: hidden;
  background: var(--line2); cursor: pointer; flex-shrink: 0;
}
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-thumb:hover img { filter: brightness(1.08); }
.tl-thumb .tl-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; background: rgba(0,0,0,.25); text-shadow: 0 0 4px rgba(0,0,0,.6);
}
.tl-thumb.tl-more {
  display: flex; align-items: center; justify-content: center;
  background: #2c3242; color: #fff; font-weight: 700; font-size: 14px;
}
.tl-thumb.tl-more:hover { background: #3a4156; }

/* 그룹보기 (전체화면: 달력 날짜/지도 클러스터/장소 모아보기 공용) */
#group-view {
  position: fixed; inset: 0; z-index: 850; background: var(--bg);
  display: flex; flex-direction: column;
}
.gv-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.gv-title { font-size: 18px; white-space: nowrap; }
.gv-sub { color: var(--muted); font-size: 13px; }
.gv-body { flex: 1; overflow-y: auto; padding: 18px 22px 100px; }
.gv-zoom { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.gv-zoom input[type=range] { width: 150px; accent-color: var(--accent); }

/* 타임라인 제목 편집 */
.tl-title-row { display: flex; align-items: center; gap: 8px; min-height: 21px; flex-wrap: wrap; }
.tl-edit { color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .12s; padding: 1px 5px; border-radius: 6px; }
.tl-row:hover .tl-edit { opacity: 1; }
.tl-edit:hover { color: var(--accent); background: var(--accent-soft); }

/* 라이트박스 줌/팬 */
.lb-stage { overflow: hidden; }
.lb-stage img { touch-action: none; user-select: none; will-change: transform; }
.lb-row textarea { flex: 1; min-width: 0; resize: vertical; font-family: inherit; }

/* ---------- 장소 ---------- */
#map { height: 62vh; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.place-names { margin-top: 16px; }

/* 사진 마커 (썸네일) */
.photo-marker .pm-wrap {
  position: relative; width: 46px; height: 46px; border-radius: 10px; overflow: hidden;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); background: var(--line2);
  transform: translate(-4px, -4px); cursor: pointer;
}
.pm-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pm-wrap .pm-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; background: rgba(0,0,0,.25);
}
/* 사진 클러스터 (아이폰 스타일: 대표 썸네일 + 개수 배지) */
.photo-cluster .pc-wrap {
  position: relative; width: 56px; height: 56px; cursor: pointer;
}
.pc-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 12px; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.pc-wrap .pc-cnt {
  position: absolute; top: -8px; right: -8px; background: var(--accent); color: #fff;
  border-radius: 11px; padding: 1px 7px; font-size: 11px; font-weight: 700;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
/* 사용자 등록 장소 핀 */
.place-pin-wrap .place-pin {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 15px;
  padding: 4px 10px 4px 6px; font-size: 12px; font-weight: 600; color: var(--fg);
  box-shadow: 0 3px 10px rgba(20,24,40,.25); cursor: pointer;
  transform: translate(-50%, -100%);
}
.place-pin-wrap .place-pin:hover { border-color: var(--accent); color: var(--accent); }
.place-form { display: flex; gap: 6px; align-items: center; }

/* ---------- 태그 목록 ---------- */
.tag-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tag-card {
  position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/10;
  background: var(--line2); cursor: pointer; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tag-card img { width: 100%; height: 100%; object-fit: cover; }
.tag-card:hover img { filter: brightness(1.06); }
.tag-card .tg-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 12px 10px;
  background: linear-gradient(transparent, rgba(10,12,18,.8)); font-weight: 600; color: #fff;
}
.tag-card .tg-label .cnt { color: #ccd2e0; font-weight: 400; font-size: 12px; margin-left: 6px; }

/* ---------- 관리자 ---------- */
.admin-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; margin-bottom: 12px; }
.card .big { font-size: 26px; font-weight: 700; }
.card .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; gap: 12px; }
.card .row span:first-child { color: var(--muted); }
.card .row span:last-child { text-align: right; }
.storage-bar { height: 9px; background: var(--line2); border-radius: 5px; overflow: hidden; margin: 10px 0 6px; }
.storage-bar i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.err-list { max-height: 300px; overflow-y: auto; font-size: 12px; }
.err-item { padding: 9px 0; border-bottom: 1px solid var(--line2); display: flex; gap: 8px; align-items: center; }
.err-item .path { flex: 1; min-width: 0; word-break: break-all; }
.err-item .msg { color: var(--danger); display: block; margin-top: 2px; }
.tool-ok { color: var(--ok); font-weight: 600; }
.tool-miss { color: var(--danger); }

/* ---------- 업로드 진행 ---------- */
#upload-progress {
  position: fixed; right: 20px; bottom: 20px; width: 320px; max-height: 50vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; z-index: 950; box-shadow: 0 10px 36px rgba(20,24,40,.16);
}
#upload-progress h4 { font-size: 13px; margin-bottom: 8px; }
.up-item { font-size: 12px; padding: 5px 0; }
.up-item .up-line { display: flex; gap: 8px; justify-content: space-between; }
.up-item .up-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 4px; margin-top: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .15s linear; }
.up-item.up-done .up-bar { display: none; }
.up-item .st-ok { color: var(--ok); }
.up-item .st-dup { color: var(--warn); }
.up-item .st-err { color: var(--danger); }

/* ---------- 드래그앤드롭 업로드 ---------- */
#drop-overlay {
  position: fixed; inset: 0; z-index: 2100; pointer-events: none;
  background: rgba(63,131,248,.12); display: flex; align-items: center; justify-content: center;
}
#drop-overlay .drop-inner {
  border: 3px dashed var(--accent); border-radius: 22px; padding: 40px 60px;
  background: var(--surface); color: var(--accent);
  font-size: 19px; font-weight: 700; box-shadow: 0 16px 60px rgba(20,24,40,.2);
}

/* ---------- 토스트 ---------- */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast-msg {
  background: var(--surface); border: 1px solid var(--line); padding: 10px 20px;
  border-radius: 24px; box-shadow: 0 6px 24px rgba(20,24,40,.14); font-size: 13px;
  animation: toast-in .2s ease;
}
.toast-msg.err { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- 모바일 ---------- */
@media (max-width: 780px) {
  #app { flex-direction: column; }

  /* 하단 탭바 */
  #sidebar {
    width: 100%; height: auto; position: fixed; bottom: 0; top: auto; z-index: 800;
    flex-direction: row; align-items: center; padding: 5px 6px;
    padding-bottom: calc(5px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(20,24,40,.06);
  }
  .brand, .nav-sep, #storage-widget, .sidebar-bottom .btn-ghost { display: none; }
  #sidebar nav { flex-direction: row; overflow-x: auto; gap: 0; }
  #sidebar nav a { padding: 10px 12px; border-radius: 12px; position: relative; }
  #sidebar nav a span { display: none; }
  #sidebar nav a .noti-badge:not(.hidden) {
    display: inline-block; position: absolute; top: 3px; right: 3px;
    font-size: 9px; padding: 0 5px; margin: 0;
  }
  #sidebar nav a svg { width: 21px; height: 21px; }
  .sidebar-bottom { flex-direction: row; }
  #btn-upload { padding: 9px 11px; }
  #btn-upload span { display: none; }

  /* 상단/본문 */
  #topbar { padding: 10px 12px 0; }
  .search-box { width: 100%; padding: 9px 14px; }
  #view { padding: 12px 10px 140px; }
  .view-title { font-size: 18px; }

  /* 필터바: 줄바꿈 대신 가로 스크롤 */
  .filterbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
  }
  .filterbar .inp, .filterbar .toggle-chip, .filterbar .btn { flex-shrink: 0; }
  .filterbar .spacer { display: none; }
  .gv-zoom input[type=range] { width: 90px; }

  /* 그리드 */
  .grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 4px; }
  .grid.sizable { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)) !important; --cs: 1 !important; }
  .cell .cell-desc { font-size: 11px; padding: 18px 6px 5px; }

  /* 달력 */
  .cal-head { gap: 6px; }
  .cal-head h2 { font-size: 17px; min-width: 0; }
  .cal-dow { padding: 8px 0; font-size: 11px; }
  .cal-day { min-height: 78px; padding: 5px 6px; }
  .cal-day .day-title { display: none; }
  .cal-day .day-meta { padding: 14px 5px 4px; }
  .year-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 7px; }

  /* 타임라인 */
  .tl-card { padding: 12px 12px; }
  .tl-row { gap: 10px; padding: 12px 0; }
  .tl-date { width: 60px; font-size: 12.5px; gap: 6px; }
  .tl-date small { display: none; }
  .tl-thumb { width: 72px; height: 54px; }

  /* 그룹보기 */
  .gv-head { padding: 9px 10px; gap: 8px; }
  .gv-title { font-size: 15px; }
  .gv-head .inp { width: 130px !important; }
  .gv-body { padding: 10px 8px 140px; }

  /* 확대보기 */
  .lb-panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 90vw); z-index: 1005; }
  #lightbox.panel-open .lb-comments { width: min(560px, calc(100vw - 24px)); left: 50%; }
  .lbc-body { max-height: 42vh; }
  #lightbox.panel-open .lb-next, #lightbox.panel-open .lb-info-toggle { right: 16px; }
  .lb-close, .lb-prev, .lb-next, .lb-info-toggle { width: 40px; height: 40px; }
  .lb-prev, .lb-next { display: none; } /* 모바일은 스와이프로 이동 */

  /* 플로팅 요소 */
  #actionbar { bottom: calc(72px + env(safe-area-inset-bottom)); padding: 8px 10px; gap: 6px; }
  #actionbar .btn { padding: 7px 10px; font-size: 12px; }
  #picker { bottom: 150px; }
  #picker.centered { bottom: auto; }
  #sharebox { width: calc(100vw - 24px); }

  /* 관리자/지도 */
  #map { height: 52vh; }
  .card { padding: 15px; }
}
