:root {
  --cream: #F7F3EC;
  --panel: #FFFDF9;
  --ink: #17140F;
  --ink-muted: #6B6459;
  --accent: #14B8A6;
  --accent-soft: #DEF5F1;
  --line: #E4DDD0;
  --font-serif: "Noto Serif KR", serif;
  --font-body: "Pretendard", "IBM Plex Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--font-body); font-size: 14px; min-height: 100vh; }
body { animation: pageIn .4s ease both; }
body.anim-settled { animation: none; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
body.leaving { animation: pageOut .28s ease both; }
@keyframes pageOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---- 상단 GNB: Post/Log와 동일 구조 ---- */
.topbar { padding: 20px max(28px, calc((100% - 1180px) / 2 + 28px)); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.topbar .mark { font-family: 'Space Grotesk'; font-weight: 700; font-size: 15px; letter-spacing: normal; text-decoration: none; color: var(--ink); cursor: pointer; }
.nav-links { display: flex; gap: 30px; font-size: 12px; letter-spacing: 0.03em; color: var(--ink-muted); }
.nav-links span { cursor: pointer; }
.nav-links span:hover { color: var(--accent); }
.nav-links span.active { color: var(--accent); font-weight: 700; cursor: default; }

.stage { max-width: 560px; margin: 0 auto; padding: 28px 24px 100px; }

/* ---- STEP 공통 ---- */
.diary-step-label{font-size:12px; font-weight:600; color:var(--ink-muted); letter-spacing:.04em; margin-bottom:8px;}
.diary-title{font-family:var(--font-serif); font-size:22px; font-weight:700; margin-bottom:20px;}
.diary-page-title{margin-bottom:28px;}
.masthead { text-align: center; margin-bottom: 40px; }
.masthead .kicker { font-size: 11px; letter-spacing: 0.22em; color: var(--accent); text-transform: uppercase; margin-bottom: 14px; }
.masthead h1 { font-family: var(--font-serif); font-weight: 700; font-size: 34px; letter-spacing: -0.01em; margin-bottom: 12px; }
.masthead .sub { font-family: var(--font-serif); font-style: italic; font-size: 14px; color: var(--ink-muted); }
.howto-steps { margin-bottom: 34px; }
.howto-steps.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.howto-steps .step { display: flex; gap: 12px; margin-bottom: 14px; align-items: center; }
.howto-steps .num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 1;
}
.howto-steps p { font-size: 13px; color: var(--ink-muted); line-height: 1.6; margin: 0; }
.diary-subhead{font-family:var(--font-serif); font-size:22px; font-weight:700; color:var(--ink); margin:36px 0 20px; letter-spacing:normal;}
.diary-subhead:first-of-type{margin-top:0;}
.cause-limit{font-weight:400; color:var(--ink-muted); font-size:11.5px;}
.cause-counter{font-weight:400; color:var(--ink-muted); font-size:11.5px; float:right;}
.diary-section{margin-bottom:36px; padding-bottom:32px; border-bottom:1px solid var(--line);}
.diary-section:last-of-type{border-bottom:none;}

/* ---- 감정 선택: 이모지 3x3 ---- */
.mood-grid{display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px;}
.mood-cell{display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:16px 4px; border-radius:16px; border:1.5px solid var(--line); background:var(--mood-color); cursor:pointer; transition:transform .12s, box-shadow .12s;}
.mood-cell .memoji{font-size:26px; line-height:1;}
.mood-cell span.mlabel{font-size:12px; color:var(--ink); font-weight:600;}
.mood-cell.selected{border-color:var(--ink); box-shadow:0 0 0 2px var(--ink) inset; transform:translateY(-2px);}

/* ---- 원인 태그 (4개 고정 카테고리 + 자주쓰는태그) ---- */
.cause-group{margin-bottom:20px;}
.cause-group h4{font-size:12.5px; color:var(--ink); font-weight:700; margin-bottom:10px; position:relative; padding-left:14px;}
.cause-group h4:before{content:''; position:absolute; left:0; top:3px; width:8px; height:8px; border-radius:50%; background:var(--group-color, var(--accent));}
.cause-freq h4:before{display:none;}
.cause-freq h4{padding-left:0;}
.cause-freq-empty{font-size:12px; color:var(--ink-muted); line-height:1.6; margin:0;}
.cause-freq{background:#F2F1EE; border:1px solid var(--line); border-radius:14px; padding:16px; margin-bottom:24px; display:flex; flex-direction:column; justify-content:center; gap:10px;}
.cause-freq h4{margin-bottom:0;}
.cause-tags{display:flex; flex-wrap:wrap; gap:8px;}
.cause-tag{font-size:13px; padding:8px 14px; border-radius:99px; border:1.5px solid var(--line); background:var(--panel); cursor:pointer; color:var(--ink); transition:all .12s;}
.cause-tag.selected{background:var(--tag-color, var(--ink)); border-color:var(--tag-color, var(--ink)); color:#2A2620; font-weight:600;}
.cause-tag.disabled{opacity:.35; cursor:not-allowed;}

/* ---- 텍스트 입력 ---- */
.diary-text-input{width:100%; border:1.5px solid var(--line); border-radius:14px; padding:14px 16px; font-size:14px; font-family:inherit; resize:none; margin-top:6px; background:var(--panel);}
.diary-text-input:focus{outline:none; border-color:var(--accent);}
.char-count{text-align:right; font-size:11.5px; color:var(--ink-muted); margin-top:6px;}

/* ---- 저장 버튼 ---- */
.diary-save-btn{width:100%; padding:15px; border-radius:14px; border:none; background:var(--ink); color:#fff; font-size:15px; font-weight:600; cursor:pointer; margin-top:8px; transition:background .15s, color .15s;}
.diary-save-btn:disabled{background:var(--line); color:var(--ink-muted); cursor:not-allowed;}

/* ---- 토스트 ---- */
.toast{position:fixed; left:50%; bottom:100px; transform:translateX(-50%) translateY(20px); background:var(--ink); color:#fff; padding:12px 22px; border-radius:99px; font-size:13.5px; font-weight:500; opacity:0; pointer-events:none; transition:all .25s; z-index:60; white-space:nowrap;}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

/* ---- 내 다이어리 플로팅 버튼 (Post inbox-fab / Log 내로그함과 동일 패턴) ---- */
.diary-fab {
  position: fixed; right: 22px; bottom: 26px; z-index: 55;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.55); color: var(--ink); text-decoration: none;
  border: 1px solid rgba(255,255,255,0.6);
  backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5);
  padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 20px rgba(20,22,27,0.16); cursor: pointer; transition: background .15s, transform .15s;
}
.diary-fab svg { width: 16px; height: 16px; flex-shrink: 0; }
.diary-fab:hover { background: rgba(255,255,255,0.75); transform: translateY(-2px); }

/* ---- 하단 모바일 GNB: Post/Log와 동일 동작 ---- */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  .nav-links { display: none; }
  body { padding-bottom: 78px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(247,243,236,0.94); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; color: var(--ink-muted); font-weight: 600; text-decoration: none; padding: 4px 0; cursor: pointer;
  }
  .bottom-nav a .bicon { line-height: 1; display: flex; align-items: center; justify-content: center; }
  .bottom-nav a .bicon svg { width: 20px; height: 20px; }
  .bottom-nav a.active { color: var(--accent); }
  .diary-fab { bottom: 92px; right: 16px; padding: 10px 16px; font-size: 12px; }
  .stage { padding: 24px 18px 90px; }
}

/* ============================================================
   모아보기 (timeline.html)
   ============================================================ */
.disclaimer { font-size: 11px; color: var(--ink-muted); text-align: center; margin-top: 16px; line-height: 1.7; }

/* 주간 리포트 카드 */
.weekly-card{background:var(--panel); border:1px solid var(--line); border-radius:18px; padding:20px; margin-bottom:26px;}
.post-loop-banner{position:relative; background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:18px 40px 18px 20px; margin-top:8px; text-align:center;}
.post-loop-banner p{font-size:13.5px; color:var(--ink); margin-bottom:12px;}
.post-loop-banner button{background:var(--ink); color:#fff; border:none; padding:10px 22px; border-radius:99px; font-size:13px; font-weight:600; cursor:pointer;}
.post-loop-close{position:absolute; top:12px; right:14px; font-size:13px; color:var(--ink-muted); cursor:pointer; padding:4px;}
.weekly-actions{display:flex; justify-content:center; gap:10px; margin:-16px 0 26px;}
.weekly-actions button{padding:10px 20px; border-radius:8px; font-size:13px; font-weight:600; cursor:pointer;}
.weekly-actions .btn-share{background:transparent; border:1px solid var(--line); color:var(--ink);}
.weekly-actions .btn-save{background:transparent; border:1px solid var(--line); color:var(--ink);}
.weekly-card .range{font-size:12px; color:var(--ink-muted); margin-bottom:10px;}
.weekly-bar{display:flex; height:14px; border-radius:99px; overflow:hidden; margin-bottom:14px; background:var(--line);}
.weekly-bar span{height:100%;}
.weekly-legend{display:flex; flex-wrap:wrap; gap:8px 14px; margin-bottom:16px;}
.weekly-legend .item{display:flex; align-items:center; gap:6px; font-size:12px; color:var(--ink-muted);}
.weekly-legend .dot{width:9px; height:9px; border-radius:50%; display:inline-block;}
.weekly-message{background:#F2F1EE; border-radius:12px; padding:16px;}
.weekly-encourage{font-size:14px; font-weight:600; line-height:1.5; margin-bottom:8px;}
.weekly-encourage .msg-label{display:block; font-size:10.5px; font-weight:700; color:var(--accent); letter-spacing:.04em; text-transform:uppercase; margin-bottom:4px;}
.weekly-guide{font-size:12.5px; color:var(--ink-muted); line-height:1.7; margin-top:12px; padding-top:12px; border-top:1px dashed rgba(0,0,0,0.08);}
.weekly-guide .msg-label{display:block; font-size:10.5px; font-weight:700; color:var(--ink); letter-spacing:.04em; text-transform:uppercase; margin-bottom:6px;}
.weekly-guide b{color:var(--ink);}

/* 캘린더 */
.cal-head{display:flex; align-items:center; gap:6px; margin-bottom:14px;}
.cal-head button{background:none; border:none; font-size:16px; cursor:pointer; color:var(--ink-muted); padding:4px 8px; flex-shrink:0;}
.cal-head button:disabled{opacity:.25; cursor:default;}
.picker-select{flex:1; min-width:0; text-align:center; font-size:14px; font-weight:700; font-family:inherit; color:var(--ink); background:transparent; border:none; padding:4px; cursor:pointer; appearance:none; -webkit-appearance:none;}
.picker-jump{font-size:11.5px !important; font-weight:600; color:var(--ink-muted) !important; background:#EFEFEF !important; border-radius:99px !important; padding:6px 12px !important; flex-shrink:0;}
.cal-grid{display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:6px; row-gap:6px;}
.cal-dow{text-align:center; font-size:10.5px; color:var(--ink-muted); padding-bottom:4px;}
.cal-cell{aspect-ratio:1; border-radius:10px; border:1px solid var(--line); position:relative; cursor:default; overflow:hidden; background:var(--panel);}
.cal-cell.empty{border:none; cursor:default; background:transparent;}
.cal-cell.has-entry{cursor:pointer;}
.cal-cell .daynum{position:absolute; top:4px; left:6px; font-size:10px; color:var(--ink); font-weight:600; z-index:2; background:rgba(255,255,255,0.72); border-radius:5px; padding:0 3px; line-height:1.5;}
.cal-cell .cal-layers{position:absolute; inset:0; display:flex; flex-direction:column;}
.cal-cell .cal-layers span{width:100%;}
.cal-cell.today{border-color:var(--ink); border-width:1.5px;}
.cal-cell.active-day{box-shadow:0 0 0 2px var(--ink) inset;}

/* 캘린더 날짜 상세보기 */
.day-detail{margin-top:14px; padding:14px; border:1px solid var(--line); border-radius:14px; background:var(--panel);}
.day-detail-head{font-size:12px; font-weight:700; color:var(--ink); margin-bottom:10px;}

/* 캘린더 상세보기: 요약형(한 줄, 이모지 없음) */
.day-summary-row{padding:8px 0; border-bottom:1px solid var(--line);}
.day-summary-row:last-child{border-bottom:none;}
.day-summary-row .tdate{font-size:12.5px; color:var(--ink); font-weight:600;}

/* 타임라인: 카드형(컬러+이모지 아바타 포함) */
.entry-row{display:flex; align-items:flex-start; gap:12px; padding:12px 14px; border:1px solid var(--line); border-radius:14px; background:var(--panel); margin-bottom:10px;}
.entry-row:last-child{margin-bottom:0;}
.entry-avatar{width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:17px;}
.entry-content{min-width:0; flex:1;}
.entry-head{display:flex; align-items:baseline; gap:8px; flex-wrap:wrap;}
.entry-mood{font-size:14px; font-weight:700; color:var(--ink);}
.entry-time{font-size:11.5px; color:var(--ink-muted);}
.entry-tags{display:flex; flex-wrap:wrap; gap:6px; margin-top:8px;}
.entry-tag{font-size:11.5px; padding:4px 10px; border-radius:99px; background:var(--cream); border:1px solid var(--line); color:var(--ink-muted);}
.tquote{font-family:'NanumSonDahaeng',sans-serif; font-size:15px; margin-top:8px; padding-left:10px; border-left:2px solid var(--line); color:var(--ink);}

/* 타임라인 (주단위 페이징) */
.tl-head{display:flex; align-items:center; gap:6px; margin:32px 0 14px;}
.tl-head button{background:none; border:none; font-size:16px; cursor:pointer; color:var(--ink-muted); padding:4px 8px; flex-shrink:0;}
.tl-head button:disabled{opacity:.25; cursor:default;}
.timeline-list{display:flex; flex-direction:column; gap:10px;}
.timeline-empty{text-align:center; color:var(--ink-muted); font-size:13px; padding:40px 0;}
