/* 하루 한 장 — 디자인 시안(04) 그대로의 색/간격. 라이트·다크는 시스템 설정을 따르고, 설정에서 고정할 수도 있음. */
:root {
  --bg: #ECEEE8;
  --ink: #20251F;
  --sub: #5A6157;
  --card: #FFFFFF;
  --line: #B9BFB4;
  --dash: #7E857A;
  --chip: #E0E3DC;
  --quiet: #E2E5DE;
  --quiet-ink: #4A5147;
  --photo: #DDE1D8;
  --mark: #F3E8A6;
  --fmt-on: #E3E8F6;
  --danger: #A33A2C;
  --on-ink: #ECEEE8;
  /* 기기 시스템 글자가 최우선. 시스템 글자에 한글이 없을 때만 아래 한글 글꼴로 넘어감 */
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', 'Noto Sans CJK KR', 'Nanum Gothic', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #141613; --ink: #E6E9E2; --sub: #A0A79B; --card: #1F221E; --line: #3C4139; --dash: #6E7569;
    --chip: #262A24; --quiet: #1A1D19; --quiet-ink: #B9BFB3; --photo: #2A2E28; --mark: #5A5120; --fmt-on: #2C3550;
    --danger: #E58C7E; --on-ink: #141613; color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #141613; --ink: #E6E9E2; --sub: #A0A79B; --card: #1F221E; --line: #3C4139; --dash: #6E7569;
  --chip: #262A24; --quiet: #1A1D19; --quiet-ink: #B9BFB3; --photo: #2A2E28; --mark: #5A5120; --fmt-on: #2C3550;
  --danger: #E58C7E; --on-ink: #141613; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--font); letter-spacing: -0.02em; font-size: 14px; line-height: 1.7; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* 최근 앱 화면/백그라운드로 갈 때 내용 가리기 */
body.cover #app { visibility: hidden; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
.screen {
  min-height: 100dvh; display: flex; flex-direction: column; gap: 12px;
  padding: max(24px, calc(env(safe-area-inset-top) + 8px)) 16px max(20px, calc(env(safe-area-inset-bottom) + 8px));
}
.screen.fixed { height: 100dvh; overflow: hidden; }
/* 글쓰기: 화면에 고정하고 높이는 보이는 영역(키보드 제외)에 맞춤 (editor.js) */
.screen.fixed.write { position: fixed; top: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; min-height: 0; padding-bottom: max(8px, calc(env(safe-area-inset-bottom) + 4px)); }
.grow { flex: 1 1 auto; min-height: 0; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- 상단바 --------------------------------------------------------- */
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.iconbtn { width: 44px; height: 44px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; border-radius: 22px; text-decoration: none; padding: 0; }
.textbtn { min-width: 44px; height: 44px; border: none; background: transparent; padding: 0 4px; display: inline-flex; align-items: center; font-size: 14px; text-decoration: none; color: var(--sub); }
.textbtn.ink { color: var(--ink); }
.bar-title { font-size: 14px; font-weight: 500; text-align: center; }
.bar-sub { font-size: 11px; color: var(--sub); }

.pill { height: 32px; padding: 0 14px; border-radius: 16px; border: none; background: var(--ink); color: var(--on-ink); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; text-decoration: none; }
.btn { height: 48px; border-radius: 24px; border: 1px solid var(--line); background: transparent; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; padding: 0 20px; }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); font-weight: 500; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { height: 36px; border-radius: 18px; padding: 0 14px; }
.btnrow { display: flex; gap: 8px; }
.btnrow > * { flex: 1; }
.btnrow > .wide { flex: 2; }

/* ---- 메인: 날짜 + 카드 ------------------------------------------------ */
.daybar { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.daylink { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 14px; border-radius: 12px; text-decoration: none; background: none; border: none; }
.daylink .big { font-size: 40px; font-weight: 600; line-height: 1; }
.daylink .small { font-size: 12px; color: var(--sub); }
.cards { display: flex; flex-direction: column; gap: 8px; }
.card { display: block; width: 100%; text-align: left; background: var(--card); border: none; border-radius: 16px; padding: 16px 18px; text-decoration: none; }
.card p { font-size: 14px; line-height: 1.7; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.card .meta { font-size: 11px; color: var(--sub); margin-top: 4px; display: flex; gap: 8px; }
.card.inbox { background: transparent; border: 1px dashed var(--dash); padding: 14px 18px; }
.card.inbox .head { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.card.inbox p { -webkit-line-clamp: 2; }
.addcard { height: 56px; background: var(--card); border: none; border-radius: 16px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.footer-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.muted { color: var(--sub); }
.empty { text-align: center; color: var(--sub); font-size: 13px; padding: 24px 0; }

/* ---- 글쓰기 / 글보기 -------------------------------------------------- */
.sheet { background: var(--card); border-radius: 18px; padding: 20px 18px; }
.editor { outline: none; min-height: 40vh; font-size: 14px; line-height: 1.7; word-break: break-word; }
/* 목록 카드와 같은 줄간격: 줄마다 간격을 더하지 않음. 빈 줄은 한 줄 높이로 남김 */
.editor p, .body p { margin: 0; min-height: 1.7em; }
.editor:empty::before { content: attr(data-placeholder); color: var(--sub); }
.body mark, .editor mark { background: var(--mark); color: inherit; padding: 0 2px; }
.body .big, .editor .big { font-size: 17px; line-height: 1.6; }
figure[data-media] { margin: 0 0 12px; position: relative; height: 180px; border-radius: 12px; background: var(--photo); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--sub); }
figure[data-media] img { width: 100%; height: 100%; object-fit: cover; display: block; }
figure[data-media] .rm { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: none; border-radius: 18px; background: rgba(32, 37, 31, 0.6); color: #fff; display: flex; align-items: center; justify-content: center; }
.toolbar { display: flex; align-items: center; gap: 4px; }
.toolbar .tb { width: 44px; height: 44px; border: none; border-radius: 22px; background: transparent; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; text-decoration: none; padding: 0; }
.fmtbar { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 22px; padding: 2px 4px; }
.fmtbar .f { width: 42px; height: 40px; border: none; border-radius: 20px; background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.fmtbar .f[aria-pressed='true'] { background: var(--ink); color: var(--on-ink); }
.swatch { width: 18px; height: 18px; border-radius: 9px; background: var(--mark); border: 1px solid rgba(0, 0, 0, 0.18); display: block; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--sub); }

/* ---- 카톡 임시글 -------------------------------------------------------- */
.bubbles { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.datepill { align-self: center; font-size: 11px; color: var(--sub); background: var(--chip); padding: 3px 10px; border-radius: 10px; margin: 6px 0; }
.brow { display: flex; align-items: center; gap: 6px; }
.brow .inner { flex: 1; display: flex; justify-content: flex-end; align-items: flex-end; gap: 6px; min-width: 0; }
.bubble { margin: 0; max-width: 78%; background: var(--card); border-radius: 16px 16px 4px 16px; padding: 9px 13px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; border: none; text-align: left; }
.bubble.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.time { font-size: 11px; color: var(--sub); white-space: nowrap; }
.chk { width: 32px; height: 44px; flex-shrink: 0; border: none; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.chk .on { width: 20px; height: 20px; border-radius: 10px; background: var(--ink); color: var(--on-ink); display: flex; align-items: center; justify-content: center; }
.chk .off { width: 18px; height: 18px; border-radius: 10px; border: 1.5px solid var(--dash); }

/* ---- 정리하기 --------------------------------------------------------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; }
.field-label { font-size: 12px; color: var(--sub); padding: 0 4px; }
.ai-btn { align-self: flex-start; }
.orig { background: var(--quiet); border-radius: 14px; padding: 14px 16px; max-height: 220px; overflow: auto; color: var(--quiet-ink); white-space: pre-line; }

/* ---- 월별 ------------------------------------------------------------ */
.monthlist { display: flex; flex-direction: column; gap: 8px; padding-bottom: 28px; }
.dayrow { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border-radius: 14px; padding: 14px 16px; text-decoration: none; border: none; text-align: left; width: 100%; }
.dayrow .num { display: flex; flex-direction: column; align-items: center; width: 26px; flex-shrink: 0; }
.dayrow .num b { font-size: 17px; font-weight: 600; line-height: 1.2; }
.dayrow .num span { font-size: 11px; color: var(--sub); }
.dayrow .txt { min-width: 0; flex: 1; }
.dayrow p { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dayrow .more { font-size: 11px; color: var(--sub); }
.monthhead { display: flex; align-items: center; }
.monthhead .t { display: flex; align-items: center; gap: 4px; height: 44px; padding: 0 6px; font-size: 14px; font-weight: 600; background: none; border: none; }
.cal { background: var(--card); border-radius: 16px; padding: 14px 10px 10px; }
.cal .wd, .cal .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.cal .wd { font-size: 11px; color: var(--sub); padding-bottom: 4px; }
.cal .cell { height: 44px; display: flex; align-items: center; justify-content: center; }
.cal .cell button { width: 40px; height: 40px; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; padding: 0; border-radius: 20px; }
.cal .cell button b { font-weight: 600; }
.cal .dot { width: 5px; height: 5px; border-radius: 3px; background: var(--ink); }
.cal .quiet { color: var(--sub); }
.cal .today b { text-decoration: underline; text-underline-offset: 3px; }

/* ---- 잠금 / 시작 / 설정 ------------------------------------------------ */
.center-screen { justify-content: center; align-items: stretch; gap: 20px; }
.center-screen h1 { font-size: 22px; font-weight: 600; margin: 0; }
.center-screen .lead { color: var(--sub); }
.start-screen { justify-content: space-between; padding-top: max(96px, calc(env(safe-area-inset-top) + 72px)); }
.start-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.center-screen h1.start-title { font-size: 40px; font-weight: 600; letter-spacing: -0.04em; line-height: 1.1; }
.start-actions { display: flex; flex-direction: column; gap: 10px; }
.start-note { font-size: 12px; text-align: center; padding: 4px 8px 0; }
.input { width: 100%; height: 52px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); padding: 0 16px; font-size: 16px; }
.input.code { text-align: center; letter-spacing: 0.3em; font-size: 22px; font-weight: 600; }
.msg { min-height: 1.7em; font-size: 13px; color: var(--danger); }
.msg.ok { color: var(--sub); }
.keybox { background: var(--card); border: 1px dashed var(--dash); border-radius: 16px; padding: 18px; text-align: center; font-size: 17px; font-weight: 600; letter-spacing: 0.06em; word-spacing: 0.3em; user-select: all; }
.note { background: var(--quiet); border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--quiet-ink); }
.list { display: flex; flex-direction: column; background: var(--card); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 18px; border: none; background: transparent; text-align: left; width: 100%; text-decoration: none; border-top: 1px solid var(--bg); }
.row:first-child { border-top: none; }
.row .l { display: flex; flex-direction: column; min-width: 0; }
.row .d { font-size: 12px; color: var(--sub); }
.row .r { color: var(--sub); font-size: 13px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.row.danger .l { color: var(--danger); }
.section-title { font-size: 12px; color: var(--sub); padding: 8px 6px 0; }
.seg { display: flex; background: var(--quiet); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 38px; border: none; background: transparent; border-radius: 11px; font-size: 13px; }
.seg button[aria-pressed='true'] { background: var(--card); font-weight: 600; }
.checkrow { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; padding: 6px 0; }
.checkrow input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--ink); flex-shrink: 0; }
.icons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.icons button { border: 2px solid transparent; background: transparent; border-radius: 16px; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; }
.icons button[aria-pressed='true'] { border-color: var(--ink); }
.icons img { width: 52px; height: 52px; border-radius: 12px; display: block; }
.modal-back { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 480px; background: var(--bg); border-radius: 22px 22px 0 0; padding: 22px 18px max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-size: 16px; }
/* 메뉴(액션 시트): 흰 카드 한 장에 줄로 나눈 항목 + 따로 떨어진 닫기 */
.modal.menu { gap: 8px; padding-top: 12px; }
.menu-group { background: var(--card); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.menu-item { height: 52px; border: none; background: transparent; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.menu-item + .menu-item { border-top: 1px solid var(--quiet); }
.menu-item.danger { color: var(--danger); }
.menu-item:active { background: var(--quiet); }
.menu-group.close .menu-item { font-weight: 500; }
mark.todo { background: #F3E8A6; color: #20251F; }
.sync-pill { position: fixed; left: 50%; bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px)); transform: translateX(-50%); z-index: 45; background: var(--chip); color: var(--quiet-ink); padding: 6px 14px; border-radius: 16px; font-size: 12px; }
.toast { position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 20px; font-size: 13px; z-index: 40; max-width: 90vw; }
.legal { max-width: 640px; margin: 0 auto; padding: 24px 18px 60px; line-height: 1.8; }
.legal h1 { font-size: 22px; } .legal h2 { font-size: 16px; margin-top: 28px; } .legal table { border-collapse: collapse; width: 100%; font-size: 13px; }
.sheet-bar { position: sticky; top: 0; background: var(--bg); padding: max(8px, env(safe-area-inset-top)) 8px 0; max-width: 640px; margin: 0 auto; }
.legal-sheet { padding-top: 4px; }
.legal-overlay { z-index: 40; } /* 동의 창(모달) 위에서도 보이게 */
.legal th, .legal td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.iconbtn:disabled { opacity: 0.3; cursor: default; }
.calbtn { width: 40px; height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; }
.cal .cell .quiet { color: var(--sub); }
.cal .nodot { width: 5px; height: 5px; display: block; }
.cal a.iconbtn { width: 40px; height: 40px; }
.monthhead h1, h1.monthhead { margin: 0; font-size: 14px; }
.monthhead .textbtn.t { gap: 4px; }
.row[href] { color: inherit; }
