/* ============ 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: 34px; line-height: 1.1; }
.brand-main .heart { color: #e8688a; font-size: 24px; }

#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;
}
.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); }

/* ---------- 그리드 ---------- */
.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); }
.cell .badge-video {
  position: absolute; right: 7px; bottom: 7px; background: rgba(15,18,26,.7);
  color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.cell .badge-fav { position: absolute; right: 7px; top: 7px; font-size: 14px; text-shadow: 0 0 4px rgba(0,0,0,.6); }
.cell .badge-status {
  position: absolute; left: 7px; bottom: 7px; font-size: 10px; padding: 2px 7px;
  border-radius: 8px; background: rgba(15,18,26,.7); color: #ffd66b;
}
.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; }

/* ---------- 선택 액션바 ---------- */
#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; }

/* ---------- 상세보기 모달 (라이트박스) ---------- */
#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; }

/* 태그 칩 */
.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: 112px; padding: 8px 9px 7px; font-size: 12px;
  border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2);
  display: flex; flex-direction: column;
}
.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 .stack { position: relative; align-self: center; margin-top: 4px; width: 68%; max-width: 96px; }
.cal-day .stack img {
  position: relative; z-index: 3; width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 7px; box-shadow: 0 1px 4px rgba(20,24,40,.18); display: block;
  border: 2px solid #fff;
}
.cal-day .stack::before, .cal-day .stack::after {
  content: ''; position: absolute; top: 3px; bottom: -3px; border-radius: 7px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(20,24,40,.10);
}
.cal-day .stack::before { left: 7px; right: -7px; z-index: 1; }
.cal-day .stack::after  { left: 4px; right: -4px; z-index: 2; }

.cal-day .day-meta {
  margin-top: auto; padding-top: 5px; display: flex; flex-direction: column; gap: 1px;
  overflow: hidden;
}
.cal-day .day-title {
  font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-day .day-count { font-size: 11px; color: var(--muted); 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; }

/* 날짜 상세 패널 */
.day-panel { margin-top: 20px; }
.day-panel .day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.day-panel .day-head h3 { font-size: 17px; }

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

/* ---------- 태그 목록 ---------- */
.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: 4px 0; display: flex; gap: 8px; justify-content: space-between; }
.up-item .st-ok { color: var(--ok); }
.up-item .st-dup { color: var(--warn); }
.up-item .st-err { color: var(--danger); }

/* ---------- 토스트 ---------- */
#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: 6px 8px;
    border-right: none; border-top: 1px solid var(--line);
  }
  .brand, .nav-sep, #storage-widget, .sidebar-bottom .btn-ghost { display: none; }
  #sidebar nav { flex-direction: row; overflow-x: auto; }
  #sidebar nav a { padding: 9px 11px; }
  #sidebar nav a span { display: none; }
  .sidebar-bottom { flex-direction: row; }
  #btn-upload span { display: none; }
  #topbar { padding: 12px 12px 0; }
  .search-box { width: 100%; }
  #view { padding: 14px 12px 130px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 4px; }
  .cal-day { min-height: 74px; padding: 5px 6px; }
  .cal-day .stack { display: none; }
  .cal-day .day-title { display: none; }
  .tl-date { width: 64px; }
  .tl-thumb { width: 70px; height: 52px; }
  .lb-panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 88vw); }
  #lightbox.panel-open .lb-next, #lightbox.panel-open .lb-info-toggle { right: 16px; }
  #actionbar { bottom: 78px; }
}
