/* ───────── 글꼴 (앱 안 fonts/, 외부 요청 없음. 제작자 배포 파일 그대로, 라이선스는 OFL.txt) ───────── */
@font-face { font-family: 'Pretendard'; font-weight: 300; font-display: swap; src: url('fonts/Pretendard-Light.woff2') format('woff2'); }
@font-face { font-family: 'Pretendard'; font-weight: 500; font-display: swap; src: url('fonts/Pretendard-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Gowun Batang'; font-weight: 400; font-display: swap; src: url('fonts/GowunBatang-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Gaegu'; font-weight: 300; font-display: swap; src: url('fonts/Gaegu-Light.ttf') format('truetype'); }
@font-face { font-family: 'Gaegu'; font-weight: 400; font-display: swap; src: url('fonts/Gaegu-Regular.ttf') format('truetype'); }

/* ───────── 색과 글씨 ───────── */
:root {
  --bg: #FDFDFB;
  --card: #F5F5F2;
  --ink: #3E3E3C;
  --text: #4A4A48;
  --soft: #8D8D88;
  --faint: #B5B5B0;
  --ghost: #DADAD5;
  --line: #EAEAE5;
  --sun: #C9A3A3;
  --danger: #B86B5E;
  --ac: #7C9CB8;
  --on-ac: #fff;
  --ac-soft: color-mix(in srgb, var(--ac) 20%, var(--bg));
  --shadow: 0 2px 12px rgba(0, 0, 0, .07);
  --f: 'Pretendard', -apple-system, sans-serif;
  --fs: 1;
  --ui: 'Pretendard', -apple-system, sans-serif;
  --w-body: 300;
  --w-num: 300;
  --w-strong: 500;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1D1D1C; --card: #272725; --ink: #ECECE8; --text: #D6D6D1; --soft: #9A9A95;
    --faint: #77776F; --ghost: #4A4A46; --line: #33332F; --sun: #B88A8A; --danger: #D98E80;
    --ac-soft: color-mix(in srgb, var(--ac) 28%, var(--bg));
    --shadow: 0 2px 12px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1D1D1C; --card: #272725; --ink: #ECECE8; --text: #D6D6D1; --soft: #9A9A95;
  --faint: #77776F; --ghost: #4A4A46; --line: #33332F; --sun: #B88A8A; --danger: #D98E80;
  --ac-soft: color-mix(in srgb, var(--ac) 28%, var(--bg));
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* 글씨체별 굵기: 손글씨·명조는 굵기 종류가 적어서 따로 맞춤 */
:root[data-font="gaegu"] { --w-num: 400; --w-strong: 400; }
:root[data-font="batang"] { --w-body: 400; --w-num: 400; --w-strong: 500; }

/* ───────── 기본 ───────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f);
  font-weight: var(--w-body);
  font-size: calc(16px * var(--fs));
  line-height: 1.9;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s, color .4s;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 3px; border-radius: 8px; }
svg { display: block; }

#view {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 22px calc(120px + env(safe-area-inset-bottom));
}
/* 상태 표시줄 자리에 종이색 띠 (위로 올린 글이 시계·배터리 뒤로 비치지 않게). 자리가 없는 화면에선 높이 0 */
body::before { content: ""; position: fixed; z-index: 35; left: 0; right: 0; top: 0; height: env(safe-area-inset-top); background: var(--bg); pointer-events: none; }
.page-enter { animation: pageIn .4s ease-out; }
@keyframes pageIn { from { opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ───────── 위쪽 줄 (읽기·쓰기·목록) ───────── */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 64px;
  font-family: var(--ui); font-size: 14px; color: var(--faint);
}
.icon-btn {
  width: 44px; height: 44px; margin-left: -12px;
  display: grid; place-items: center;
  border: 0; background: none; border-radius: 50%;
  color: var(--faint);
  transition: background .2s, transform .15s, color .2s;
}
.icon-btn:hover { background: var(--card); color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 22px; height: 22px; }
.text-btn { border: 0; background: none; padding: 10px 0 10px 12px; color: var(--soft); font-family: var(--ui); font-size: 14px; transition: color .2s; }
.text-btn:hover { color: var(--ac); }
.save-state { color: var(--ac); font-family: var(--ui); font-size: 13px; transition: opacity .3s; }
.save-state[data-s="idle"] { opacity: 0; }
.save-state[data-s="saving"] { color: var(--faint); }
.save-state[data-s="error"], .save-state[data-s="low"] { color: var(--danger); }

/* ───────── 첫 화면: 달 + 달력 ───────── */
.mhead { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 36px; }
.big-month {
  border: 0; background: none; padding: 0;
  font-size: calc(64px * var(--fs)); line-height: .85; font-weight: var(--w-num); color: var(--ink);
  transition: transform .2s;
}
.big-month:active { transform: scale(.96); }
.mside { text-align: right; color: var(--faint); font-size: calc(14px * var(--fs)); line-height: 1.5; }
.mside b { font-weight: var(--w-strong); color: var(--soft); }
.mnav { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.mnav button { border: 0; background: none; width: 30px; height: 30px; display: grid; place-items: center; color: var(--faint); border-radius: 50%; transition: background .2s, color .2s; }
.mnav button:hover { background: var(--card); color: var(--text); }
.mnav svg { width: 16px; height: 16px; }
.mnav .mlabel { width: auto; height: auto; padding: 2px 6px; border-radius: 8px; font-weight: var(--w-strong); color: var(--soft); font-size: inherit; }
.mnav .mlabel:active { background: var(--card); }

/* 달 고르기 창 */
.mpick-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.mpick-head h3 { margin: 0; }
.mpick-year { display: flex; align-items: center; gap: 2px; font-family: var(--ui); }
.mpick-year b { min-width: 48px; text-align: center; font-weight: var(--w-strong); color: var(--ink); }
.mpick-year button { border: 0; background: none; width: 36px; height: 36px; display: grid; place-items: center; color: var(--soft); border-radius: 50%; }
.mpick-year button:active { background: var(--card); }
.mpick-year svg { width: 16px; height: 16px; }
.mgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mcell { border: 0; background: none; padding: 10px 0 8px; border-radius: 12px; color: var(--text); font-size: calc(15px * var(--fs)); line-height: 1.4; transition: background .2s; }
.mcell:active { background: var(--card); }
.mcell i { display: block; width: 4px; height: 4px; margin: 3px auto 0; border-radius: 50%; }
.mcell i.dot { background: var(--ac); }
.mcell.future { color: var(--faint); }
.mcell.on { background: var(--ink); color: var(--bg); font-weight: var(--w-strong); }
.mcell.on i.dot { background: var(--bg); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-top: 26px; row-gap: 6px; font-size: calc(15px * var(--fs)); }
.cal .w { color: var(--faint); font-family: var(--ui); font-size: 12px; padding-bottom: 6px; }
.cal .sun { color: var(--sun); }
/* 달 넘길 때 민 방향에서 살짝 들어오기 */
.cal.from-next, #view.from-next { animation: calFromNext .25s ease-out both; }
.cal.from-prev, #view.from-prev { animation: calFromPrev .25s ease-out both; }
@keyframes calFromNext { from { transform: translateX(16px); } }
@keyframes calFromPrev { from { transform: translateX(-16px); } }
.day {
  height: 44px; margin: 0 3px;
  border: 0; background: none; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  font-weight: var(--w-body);
  transition: color .25s, transform .15s;
  animation: fadeIn .35s both; animation-delay: calc(var(--i) * 8ms);
}
.day .n {
  width: 34px; height: 34px; border-radius: 50%; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid transparent; transition: background .25s, border-color .25s;
}
.day .dot { width: 4px; height: 4px; margin-top: 4px; border-radius: 50%; }
.day:hover .n { background: var(--card); }
.day:active { transform: scale(.9); }
.day.has { color: var(--ink); }
.day.has .dot { background: var(--ac); }
.day.today { color: var(--ink); font-weight: var(--w-strong); }
.day.today .n { border-color: var(--ac); }
.day.sel .n { background: var(--line); }
.day.future { color: var(--faint); }

.peeks { margin-top: 22px; display: grid; gap: 10px; }
.peek {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; border-radius: 16px;
  background: var(--card);
  animation: rise .35s both;
  transition: transform .2s;
}
.peek:active { transform: scale(.98); }
.peek-body { flex: 1; min-width: 0; }
.peek small { display: block; font-family: var(--ui); font-size: 12px; color: var(--faint); line-height: 1.6; }
.peek p { margin: 0; color: var(--text); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.peek.empty { color: var(--faint); justify-content: space-between; }
.peek.empty a { color: var(--ac); font-family: var(--ui); font-size: 14px; }
.peek.ago { background: none; border: 1px solid var(--line); }
.peek.ago small b { color: var(--ac); font-weight: inherit; }
.thumb-sm { width: 52px; height: 52px; flex: none; border-radius: 10px; object-fit: cover; background: var(--line); }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 4px 4px;
  font-family: var(--ui); font-size: 13px; color: var(--soft); line-height: 1.6;
  animation: rise .35s both;
}
.banner p { margin: 0; flex: 1 1 180px; }
.banner button { border: 0; background: none; padding: 6px 4px; font-family: var(--ui); font-size: 13px; color: var(--faint); }
.banner button.go { color: var(--ac); }
.banner.line { flex-wrap: nowrap; gap: 6px; margin-top: 18px; padding: 0 2px; font-size: 12px; color: var(--faint); }
.banner.line p { flex: 1; }
.banner.line .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--sun); flex: none; }
.banner.line button { padding: 6px 2px; }

/* ───────── 폴더 탭 ───────── */
.ftabs {
  display: flex; align-items: center; gap: 26px;
  padding-top: 34px;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 -22px; padding-left: 22px; padding-right: 22px;
}
.ftabs::-webkit-scrollbar { display: none; }
.ftab {
  position: relative; flex: none;
  border: 0; background: none; padding: 2px 0 6px;
  font-weight: var(--w-body); font-size: calc(17px * var(--fs)); color: var(--faint);
  white-space: nowrap;
  transition: color .25s;
}
.ftab:hover { color: var(--soft); }
.ftab.on { color: var(--ink); font-weight: var(--w-strong); }
.ftab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--ac); animation: grow .35s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes grow { from { transform: scaleX(0); } }
.ftab.add { color: var(--ghost); font-size: calc(19px * var(--fs)); }
.ftabs + .mhead { padding-top: 24px; }

/* 목록형 폴더 */
.nhead { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 24px; margin-bottom: 6px; }
.nhead h1 { margin: 0; font-size: calc(30px * var(--fs)); font-weight: var(--w-strong); color: var(--ink); line-height: 1.1; }
.nhead span { font-family: var(--ui); font-size: 13px; color: var(--faint); }
.nside { display: flex; align-items: baseline; gap: 12px; }
.nside a { font-family: var(--ui); font-size: 15px; color: var(--ac); padding: 4px 0; }
.nrow {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  animation: rise .35s both; animation-delay: calc(var(--i) * 30ms);
  transition: opacity .2s;
}
.nrow:active { opacity: .6; }
.nbody { flex: 1; min-width: 0; }
.nbody b { display: block; font-weight: var(--w-strong); color: var(--ink); font-size: calc(17px * var(--fs)); line-height: 1.45; }
.nbody p { margin: 2px 0 0; color: var(--soft); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.nbody small { font-family: var(--ui); font-size: 12px; color: var(--faint); }

/* 쓰기 화면 폴더 칩 */
.fchip {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 50%; padding: 6px 14px; border-radius: 999px;
  border: 0; background: var(--card); color: var(--soft);
  font-family: var(--ui); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: transform .15s, color .2s;
}
.fchip:active { transform: scale(.95); }
.fchip i { font-style: normal; font-size: 10px; color: var(--faint); }

/* 아래에서 올라오는 창 */
.overlay.sheet-wrap { place-items: end center; padding: 0; }
.sheet {
  width: min(100%, 560px);
  background: var(--bg);
  border-radius: 26px 26px 0 0;
  padding: 12px 22px calc(28px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
  animation: sheetUp .35s cubic-bezier(.2, .8, .2, 1) both;
}
.overlay.sheet-wrap.closing { animation: fadeOut .22s forwards; }
.overlay.sheet-wrap.closing .sheet { animation: sheetDown .22s forwards; }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes fadeOut { to { opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--ghost); margin: 0 auto 16px; }
.sheet h3 { margin: 0 0 6px; font-weight: var(--w-strong); font-size: calc(20px * var(--fs)); color: var(--ink); }
.frow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.frow.pick { padding: 14px 0; transition: opacity .2s; }
.frow.pick:active { opacity: .6; }
.frow b { flex: 1; font-weight: var(--w-strong); color: var(--ink); font-size: calc(17px * var(--fs)); }
.fdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.fname { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 0; text-align: left; font-size: calc(17px * var(--fs)); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fname:hover { color: var(--ac); }
.kind { font-family: var(--ui); font-size: 11px; color: var(--soft); background: var(--card); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.cnt { font-family: var(--ui); font-size: 12px; color: var(--faint); min-width: 30px; text-align: right; }
.arrows { display: flex; }
.arrows button { width: 30px; height: 34px; border: 0; background: none; color: var(--soft); border-radius: 8px; font-size: 14px; }
.arrows button:hover:not(:disabled) { background: var(--card); }
.arrows button:disabled { color: var(--ghost); cursor: default; }
.check { color: var(--ac); font-family: var(--ui); }
.newf { border: 0; background: none; padding: 14px 0 4px; color: var(--ac); font-size: calc(16px * var(--fs)); }
.sheet-note { margin: 12px 0 0; font-family: var(--ui); font-size: 12px; line-height: 1.7; color: var(--faint); }

/* ───────── 첫 화면 위쪽 메뉴 (쓰기 · ···) ───────── */
.htop { display: flex; align-items: flex-end; gap: 12px; }
.htop .ftabs { flex: 1; min-width: 0; margin-right: 0; padding-right: 0; }
.htop .ftabs.fade { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
.tlinks { flex: none; display: flex; align-items: center; gap: 0; font-family: var(--ui); font-size: 14px; }
.search-btn { width: 40px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--soft); transition: background .2s, color .2s; }
.search-btn:hover { background: var(--card); color: var(--text); }
.search-btn svg { width: 19px; height: 19px; }
.more { position: relative; }
.more-btn { border: 0; background: none; width: 40px; height: 36px; margin-right: -10px; border-radius: 10px; color: var(--soft); font-size: 18px; letter-spacing: 1px; line-height: 1; transition: background .2s, color .2s; }
.more-btn:hover, .more.open .more-btn { background: var(--card); color: var(--text); }
.more-menu {
  position: absolute; z-index: 40; top: calc(100% + 6px); right: -10px;
  min-width: 140px; padding: 6px 0; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translateY(-4px);
  transition: opacity .18s, transform .18s;
}
.more.open .more-menu { opacity: 1; pointer-events: auto; transform: none; }
.more-menu a, .more-menu button { display: block; width: 100%; padding: 11px 18px; border: 0; background: none; text-align: left; font-family: var(--ui); color: var(--text); font-size: 15px; white-space: nowrap; }
.more-menu a:hover, .more-menu button:hover { background: var(--card); }

/* ───────── 검색 ───────── */
.search-box {
  width: 100%; margin: 6px 0 14px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  font: inherit; font-family: var(--ui); font-size: 16px; color: var(--ink); outline: none;
}
.search-box:focus { border-color: var(--ac); }
.search-box::placeholder { color: var(--faint); }
.search-results mark { background: var(--ac-soft); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.peek-more { display: flex; justify-content: flex-end; }
.peek-more a { padding: 4px 2px; color: var(--ac); font-family: var(--ui); font-size: 14px; }

/* ───────── 날짜 머리 (읽기·쓰기) ───────── */
.dhead { position: relative; display: flex; align-items: center; gap: 12px; margin: 14px 0 22px; }
.dnum { font-size: calc(36px * var(--fs)); line-height: 1; font-weight: var(--w-num); color: var(--ink); }
.dtext { font-size: calc(14px * var(--fs)); line-height: 1.45; color: var(--soft); }
.ymd { color: var(--faint); font-size: .9em; margin-left: 2px; }
.date-pick { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dhead.pickable .dtext::after { content: " ✎"; color: var(--ghost); font-size: .85em; }

/* ───────── 읽기 ───────── */
.title { font-size: calc(19px * var(--fs)); font-weight: var(--w-strong); color: var(--ink); margin: 0 0 10px; animation: rise .5s both; }
.prose p { margin: 0 0 1.1em; animation: rise .6s both; animation-delay: calc(var(--i) * 90ms + 80ms); }
.sign { text-align: right; color: var(--faint); font-size: calc(14px * var(--fs)); margin-top: 6px; animation: fadeIn .8s .4s both; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: var(--line); cursor: zoom-in; animation: rise .5s both; animation-delay: calc(var(--i) * 80ms + 200ms); transition: transform .25s; }
.photos img:hover { transform: scale(1.02); }
.read-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 42px; padding-top: 16px; border-top: 1px solid var(--line); font-family: var(--ui); font-size: 13px; color: var(--faint); }
.read-foot a, .read-foot button { border: 0; background: none; padding: 8px 0; color: var(--soft); font-family: var(--ui); font-size: 13px; transition: color .2s; }
.read-foot a:hover, .read-foot button:hover { color: var(--ac); }
.read-foot .danger:hover { color: var(--danger); }

/* ───────── 쓰기 ───────── */
.writer {
  width: 100%; min-height: 7.8em; /* 네 줄에서 시작해 글 따라 늘어남 (화면 절반이면 키보드가 올라올 때 화면이 밀림) */
  border: 0; outline: none; resize: none; overflow: hidden;
  padding: 0; background: transparent;
  line-height: 1.95; font-weight: var(--w-body);
  caret-color: var(--ac);
}
.writer::placeholder { color: var(--ghost); }
.edit-photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.edit-photos:empty { display: none; }
.ephoto { position: relative; width: 84px; height: 84px; animation: pop .4s cubic-bezier(.2, .9, .3, 1.3) both; }
.ephoto.wait { border-radius: 12px; background: var(--line); animation: pop .4s cubic-bezier(.2, .9, .3, 1.3) both, breathe 1.2s ease-in-out .4s infinite alternate; }
@keyframes breathe { to { opacity: .45; } }
/* 고르자마자 내 사진을 작게 흐리게, 저장이 끝나면 또렷하게 */
.ephoto.wait.thumb { background: none; animation: pop .4s cubic-bezier(.2, .9, .3, 1.3) both; }
.ephoto canvas { display: block; width: 100%; height: 100%; border-radius: 12px; filter: blur(5px) saturate(.6); opacity: .55; transform: scale(.94); }
.ephoto.sharp img { animation: sharpen .5s ease-out; }
@keyframes sharpen { from { filter: blur(5px) saturate(.6); opacity: .55; transform: scale(.94); } }
.write-rest { min-height: 40vh; cursor: text; }
.ephoto img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; background: var(--line); }
.ephoto button { position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 12px; line-height: 1; }
.tools {
  position: fixed; z-index: 30;
  left: 0; right: 0; bottom: 0;
  padding: 12px 22px calc(18px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center;
  max-width: 560px; margin: 0 auto;
  background: linear-gradient(transparent, var(--bg) 35%);
}
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--card); color: var(--soft); display: grid; place-items: center; transition: transform .15s, color .2s; }
.round:active { transform: scale(.9); }
.round.full { opacity: .4; } /* 사진 칸이 다 참 (눌리긴 하고, 누르면 알림) */
.round svg { width: 22px; height: 22px; }

/* ───────── 버튼 ───────── */
.pill {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 26px; border-radius: 999px;
  border: 0; background: var(--ac); color: var(--on-ac);
  font-family: var(--ui); font-size: 15px; font-weight: 500;
  transition: transform .15s, filter .2s;
}
.pill:hover { filter: brightness(1.04); }
.pill:active { transform: scale(.95); }
.pill.quiet { background: var(--card); color: var(--text); }
.pill.danger { background: var(--card); color: var(--danger); }
.pill.sm { min-height: 40px; padding: 0 18px; font-family: var(--ui); font-size: 14px; }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .22; transform: scale(0); pointer-events: none; animation: ripple .6s ease-out forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ───────── 모든 페이지 ───────── */
.lhead { display: flex; align-items: flex-end; justify-content: space-between; padding-top: 36px; margin-bottom: 8px; }
.lhead h1 { margin: 0; font-size: calc(30px * var(--fs)); font-weight: var(--w-strong); color: var(--ink); line-height: 1; }
.lhead span { font-family: var(--ui); font-size: 13px; color: var(--faint); }
.month-label { margin: 30px 0 4px; font-size: calc(14px * var(--fs)); color: var(--faint); }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  animation: rise .35s both; animation-delay: calc(var(--i) * 30ms);
  transition: opacity .2s;
}
.row:active { opacity: .6; }
.rnum { width: 34px; flex: none; font-size: calc(24px * var(--fs)); font-weight: var(--w-num); color: var(--ink); line-height: 1; text-align: center; }
.rbody { flex: 1; min-width: 0; }
.rbody small { display: block; font-family: var(--ui); font-size: 12px; color: var(--faint); }
.rbody p { margin: 0; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty-note { text-align: center; color: var(--faint); padding: 60px 0; line-height: 2; }

/* ───────── 설정 ───────── */
.page-title { font-size: calc(26px * var(--fs)); font-weight: var(--w-strong); color: var(--ink); margin: 6px 0 4px; }
.panel {
  background: var(--card); border-radius: 18px;
  padding: 18px; margin-top: 14px;
  font-family: var(--ui); font-size: 14px; line-height: 1.7;
  animation: rise .4s both; animation-delay: calc(var(--i, 0) * 50ms);
}
.panel h3 { margin: 0 0 10px; font-size: 15px; font-weight: var(--w-strong); color: var(--ink); }
.panel p { margin: 0 0 12px; }
.note { color: var(--soft); font-size: 13px; }
.guard { list-style: none; padding: 0; margin: 0 0 14px; }
.guard li { position: relative; padding: 8px 0 8px 26px; border-bottom: 1px solid var(--line); color: var(--soft); font-size: 13px; }
.guard li:last-child { border-bottom: 0; }
.guard li b { display: block; font-weight: var(--w-strong); color: var(--text); font-size: 14px; }
.guard li::before { position: absolute; left: 2px; top: 9px; }
.guard li.ok::before { content: "✓"; color: var(--ac); }
.guard li.warn::before { content: "!"; color: var(--danger); left: 6px; }
.guard li.bad::before { content: "✕"; color: var(--danger); }
/* 백업 칸: 상태 한 줄 + "더 보기"로 접기 */
.bstate { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; color: var(--ink); font-size: 14px; }
.bstate .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sun); flex: none; }
.b-alert { display: flex; gap: 8px; margin: 0 0 10px; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--danger); font-size: 13px; }
.b-alert b { font-weight: var(--w-strong); }
.b-more, .b-snaps { width: 100%; }
.b-more { margin-top: 14px; }
.b-more summary, .b-snaps summary { list-style: none; cursor: pointer; }
.b-more summary::-webkit-details-marker, .b-snaps summary::-webkit-details-marker { display: none; }
.b-more > summary { display: inline-block; padding: 4px 0; color: var(--soft); font-size: 13px; }
.b-more[open] > summary { color: var(--faint); margin-bottom: 6px; }
details:not([open]) > summary .opened, details[open] > summary .closed { display: none; }
.b-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--soft); }
.b-row:first-of-type { border-top: 1px solid var(--line); }
.b-row b { font-weight: var(--w-strong); color: var(--text); font-size: 14px; }
.b-row .sp { flex: 1; }
.b-row > .ok { color: var(--ac); width: 14px; flex: none; }
.b-row > .warn { color: var(--danger); width: 14px; flex: none; text-align: center; }
.b-snaps > summary { display: flex; align-items: baseline; gap: 10px; }
.b-snaps .go { color: var(--ac); }
.b-snaps .snap-list { margin-top: 6px; }
.b-snaps .snap-list li:first-child { border-top: 1px solid var(--line); }
.b-snaps .snap-list li:last-child { border-bottom: 0; }
.b-more .btn-row { margin-top: 12px; }
.snap-list { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; }
.snap-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.snap-list small { color: var(--faint); }
.link-btn { border: 0; background: none; color: var(--ac); padding: 6px 2px; font-family: var(--ui); font-size: 13px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--soft); transition: background .2s, color .2s, border-color .2s; }
.choice[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.remind-time { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--soft); }
.remind-time input { font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.warn-text { color: var(--danger); }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--card); outline: 2px solid transparent; padding: 0; transition: outline-color .2s, transform .15s; }
.swatch:active { transform: scale(.9); }
.swatch[aria-pressed="true"] { outline-color: var(--ink); }

/* ───────── 잠금 ───────── */
.lock {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg);
  animation: fadeIn .3s both;
}
.lock.leaving { animation: lockOut .45s ease-in forwards; }
@keyframes lockOut { to { opacity: 0; transform: scale(1.03); } }
.lock h2 { margin: 0; font-weight: var(--w-strong); font-size: calc(26px * var(--fs)); color: var(--ink); }
.lock h2.brand { display: flex; align-items: center; gap: 10px; font-weight: 300; letter-spacing: .18em; color: var(--soft); }
.pin-dots { display: flex; gap: 14px; height: 16px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--faint); transition: background .15s, transform .15s; }
.pin-dots i.on { background: var(--ac); border-color: var(--ac); transform: scale(1.1); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 70px); gap: 12px; }
.keypad button { height: 70px; border-radius: 50%; border: 0; background: var(--card); font-size: calc(22px * var(--fs)); font-weight: var(--w-strong); transition: transform .1s, background .2s; }
.keypad button:active { transform: scale(.9); background: var(--ac-soft); }
.keypad button.txt { background: none; font-family: var(--ui); font-size: 13px; color: var(--soft); }
.lock-hint { min-height: 1.5em; color: var(--soft); font-family: var(--ui); font-size: 13px; }
.lock-forgot { margin-top: -10px; padding: 6px 10px; border: 0; background: none; font-family: var(--ui); font-size: 13px; color: var(--faint); }
.lock-wait { min-height: 3em; margin: 0; text-align: center; color: var(--soft); font-family: var(--ui); font-size: 13px; line-height: 1.6; }
.lock-wait b { color: var(--ink); font-weight: var(--w-strong); }
.lock ~ .overlay { z-index: 110; } /* 잠금 화면 위에 뜨는 창 */
.rcode { margin: 14px 0; padding: 12px 0; border: 1px solid var(--line); border-radius: 12px; text-align: center; font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: .12em; color: var(--ink); user-select: all; }
hr.split { border: 0; border-top: 1px solid var(--line); margin: 16px 0 12px; }

/* ───────── 창, 알림 ───────── */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 20, 18, .35);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn .2s both;
}
.dialog {
  width: min(100%, 400px);
  background: var(--bg); border-radius: 22px;
  padding: 24px 22px 18px;
  box-shadow: var(--shadow);
  font-family: var(--ui); font-size: 14px;
  animation: pop .3s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.dialog h3 { margin: 0 0 10px; font-weight: var(--w-strong); font-size: 17px; color: var(--ink); }
.dialog p { margin: 0 0 12px; color: var(--soft); }
.dialog .btn-row { justify-content: flex-end; margin-top: 16px; }
.field { display: block; margin: 10px 0; font-size: 13px; color: var(--soft); }
.field input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); }
.lightbox { cursor: zoom-out; background: rgba(20, 20, 18, .85); }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 12px; animation: pop .3s both; }

#toast {
  position: fixed; z-index: 95;
  left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: max-content; max-width: min(calc(100% - 32px), 420px);
  padding: 11px 18px; border-radius: 18px;
  background: var(--ink); color: var(--bg);
  font-family: var(--ui); font-size: 13px; line-height: 1.5; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .35s cubic-bezier(.2, .9, .3, 1.2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { flex: none; border: 0; background: none; color: var(--ac); padding: 4px; font-family: var(--ui); font-size: 13px; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 380px) {
  #view { padding-left: 16px; padding-right: 16px; }
  .day { margin: 0 1px; }
  .keypad { grid-template-columns: repeat(3, 64px); }
  .keypad button { height: 64px; }
}

/* ───────── 오픈소스 라이선스 ───────── */
.lic-link { display: flex; justify-content: space-between; margin-top: 18px; padding: 14px 4px; font-family: var(--ui); font-size: 13px; color: var(--faint); }
.lic-link:hover { color: var(--soft); }
.lic-link + .lic-link { margin-top: 0; }
.policy-sum { margin: 16px 0 8px; padding: 14px 16px; border-radius: 12px; background: var(--card); font-family: var(--ui); font-size: 14px; line-height: 1.7; color: var(--ink); }
.policy h3 { margin: 22px 0 6px; font-family: var(--ui); font-size: 14px; font-weight: var(--w-strong); color: var(--ink); }
.policy p { margin: 6px 0 0; font-family: var(--ui); font-size: 13px; line-height: 1.8; color: var(--soft); overflow-wrap: anywhere; }
.policy .todo { color: var(--danger); }
.credit { padding: 14px 0; border-bottom: 1px solid var(--line); }
.credit b { font-weight: var(--w-strong); color: var(--ink); }
.credit small { margin-left: 6px; font-family: var(--ui); font-size: 12px; color: var(--faint); }
.credit p { margin: 6px 0 0; font-family: var(--ui); font-size: 12px; line-height: 1.6; color: var(--soft); overflow-wrap: anywhere; }
.lic-full { margin-top: 18px; }
.lic-full summary { cursor: pointer; padding: 6px 0; font-family: var(--ui); font-size: 14px; color: var(--ac); }
.lic-full pre { margin: 10px 0 0; padding: 14px; border-radius: 12px; background: var(--card); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.6; color: var(--soft); }
