/* ===== SOOM · 하루 한 줄 ===== */
:root {
  --main: #d7e6fa;                        /* 메인 배경 (레퍼런스 블루) */
  --page-bg: var(--main);
  --lh: 28px;                             /* 노트 줄 간격 */
  --ink: #111111;
  --ink-2: rgba(17, 17, 17, .55);
  --ink-3: rgba(17, 17, 17, .3);
  --line: rgba(17, 17, 17, .18);          /* 격자·점선 */
  --rule: #111111;
  --surface: #ffffff;
  --surface-2: #ececea;
  --danger: #d93a3f;
  --shadow-lg: 0 2px 6px rgba(0,0,0,.06), 0 24px 60px rgba(0,0,0,.16);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --display: "Dela Gothic One", "Arial Black", "Pretendard Variable", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #141519;
    --ink: #eef0f4; --ink-2: rgba(238,240,244,.6); --ink-3: rgba(238,240,244,.3); --line: rgba(238,240,244,.18); --rule: rgba(238,240,244,.85);
    --surface: #1e1f24; --surface-2: #2b2c32; --danger: #ff6b6f;
    --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page-bg: #141519;
  --ink: #eef0f4; --ink-2: rgba(238,240,244,.6); --ink-3: rgba(238,240,244,.3); --line: rgba(238,240,244,.18); --rule: rgba(238,240,244,.85);
  --surface: #1e1f24; --surface-2: #2b2c32; --danger: #ff6b6f;
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--page-bg); height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0; background: var(--page-bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5;
  letter-spacing: -.02em; -webkit-font-smoothing: antialiased;
  /* 한 화면 고정: 앱바 + 보기(스크롤 영역) + 아래 버튼 */
  height: 100dvh; overflow: hidden; overscroll-behavior: none; display: flex; flex-direction: column;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
/* 앱처럼: 두 번 탭 확대 없음, 길게 눌러도 화면 글자가 잡히지 않게 (글 쓰는 칸·기록 글은 예외) */
html, body, button, input, textarea, label, dialog { touch-action: manipulation; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
textarea, input, .entry-text { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.spacer { flex: 1; }
.dp-num, .dp-small, .dp-side, .vh-big, .vh-name, .yc, .mc-d, .lr-d, .mweek { font-synthesis: none; }

/* ---- app bar ---- */
.appbar {
  flex: none; width: 100%; max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 6px;
}
.appbar-title {
  margin: 0; border: 0; background: none; justify-self: center; padding: 6px 10px; line-height: 1.2; user-select: none;
  font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: .04em; font-synthesis: none;
}
.ico-view rect { fill: var(--ink-3); stroke: none; }
.ico-view rect.on { fill: var(--ink); }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  display: inline-grid; place-items: center; transition: background .15s, transform .15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.icon-btn.on { background: var(--ink); color: var(--page-bg); }

/* ---- 보기 영역 = 유일한 스크롤 영역 ---- */
.view {
  flex: 1; min-height: 0; width: 100%; max-width: 560px; margin: 0 auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  touch-action: pan-y; scrollbar-width: none;
}
.view::-webkit-scrollbar { display: none; }
.view.out-left > * { animation: outL .16s ease-in forwards; }
.view.out-right > * { animation: outR .16s ease-in forwards; }
.view.in-right > * { animation: inR .26s cubic-bezier(.2,.9,.3,1); }
.view.in-left > * { animation: inL .26s cubic-bezier(.2,.9,.3,1); }
@keyframes outL { to { opacity: 0; transform: translateX(-36px); } }
@keyframes outR { to { opacity: 0; transform: translateX(36px); } }
@keyframes inR { from { opacity: 0; transform: translateX(36px); } }
@keyframes inL { from { opacity: 0; transform: translateX(-36px); } }

/* ===== 하루 ===== */
/* 기본은 화면에 딱 맞게(노트가 남는 높이를 채움), 글·사진이 넘치면 페이지 전체가 자연스럽게 스크롤 */
.day-page { position: relative; min-height: 100%; display: flex; flex-direction: column; padding: 8px 24px 6px; }
.dp-head { flex: none; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 10px; }
.dp-rule { width: 64px; height: 1.5px; background: var(--rule); }
.dp-small { font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1; letter-spacing: 0; }
.dp-side { position: absolute; top: 26px; writing-mode: vertical-rl; font-family: var(--display); font-weight: 400; font-size: 13px; letter-spacing: .02em; }
.dp-side.left { left: 18px; }
.dp-side.right { right: 18px; }
.dp-num {
  flex: none; font-family: var(--display); font-weight: 400; font-size: clamp(116px, 35vw, 186px); line-height: 1; letter-spacing: 0;
  text-align: center; margin: 26px 0 24px; user-select: none;
}
.dp-photo {
  flex: none; display: block; width: 100%; border: 0; padding: 0; margin: 0 0 18px; border-radius: 4px; overflow: hidden;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}
.dp-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 30dvh; object-fit: cover; }
.note { flex: 1; display: flex; border-top: 1px solid var(--rule); min-height: calc(var(--lh) * 4 + 1px); }
#noteText {
  flex: 1; display: block; width: 100%; border: 0; outline: none; resize: none; overflow: hidden; padding: 0; margin: 0;
  /* 줄 하나짜리 타일을 반복 → 소수점 위치에서도 모든 줄 두께가 똑같이 */
  background: linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px)) 0 0 / 100% var(--lh) repeat-y;
  color: var(--ink); font-size: 13px; font-weight: 600; line-height: var(--lh); letter-spacing: -.02em; text-align: center;
  caret-color: var(--ink); word-break: keep-all; overflow-wrap: anywhere;
}
#noteText::placeholder { color: var(--ink-3); font-weight: 500; }
.dp-foot { flex: none; display: flex; justify-content: space-between; align-items: flex-start; margin-top: 12px; font-size: 14px; font-weight: 700; line-height: 1.55; }
.foot-right { display: flex; align-items: center; gap: 8px; }
#saveState { font-size: 11px; font-weight: 500; color: var(--ink-3); }
#saveState:empty { display: none; }
.foot-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--ink); }
@media (max-height: 640px) {
  .dp-num { font-size: clamp(80px, 23vw, 120px); margin: 16px 0 14px; }
  .dp-head { margin-top: 4px; }
}

/* ===== 공통: 한 해 / 한 달 / 목록 (레퍼런스: 검정 실선 격자 · 굵은 구분선 · 점선) ===== */
.pane { padding: 26px 12px 36px; }
.vh {
  display: flex; justify-content: space-between; align-items: stretch; gap: 12px;
  padding: 0 4px 18px; border-bottom: 1.5px solid var(--ink);
}
.vh-big {
  border: 0; background: none; padding: 0; color: var(--ink); text-align: left;
  font-family: var(--display); font-weight: 400; font-size: 56px; line-height: .8; letter-spacing: -.02em;
}
.vh.year .vh-big { font-size: 42px; align-self: flex-end; }
.vh-right { flex: none; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; gap: 12px; }
.vh-name { font-family: var(--display); font-weight: 400; font-size: 15px; line-height: 1; letter-spacing: 0; }
.vh-stats { display: flex; gap: 12px; font-family: var(--display); font-size: 11px; line-height: 1; }
.vh-stats span { display: inline-flex; align-items: center; gap: 5px; }
.ico-s { width: 11px; height: 11px; stroke-width: 1.4; stroke-linecap: butt; }
.ico-s .fill { fill: currentColor; stroke: none; }

/* ---- 한 해: 16칸 격자 ---- */
.ygrid { display: grid; grid-template-columns: repeat(16, 1fr); margin-top: 22px; border-top: 1px solid var(--ink); border-left: 1px solid var(--ink); }
.yc {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  border-radius: 0; background: transparent; color: var(--page-bg);
  font-family: var(--display); font-weight: 400; font-size: 8px; line-height: 1; display: grid; place-items: center;
}
.yc.w::before { content: ""; position: absolute; inset: 3px 2px; background: linear-gradient(to bottom, transparent 2px, var(--ink) 2px) 0 0 / 100% 3px repeat-y; }
.yc.p::after { content: ""; position: absolute; width: 7px; height: 7px; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ink); }
.yc.w.p::after { box-shadow: 0 0 0 2px var(--page-bg); }
.yc.t { background: var(--ink); }
.yc.t::before { display: none; }
.yc.t::after { display: none; }
.yc.f { cursor: default; }
.yc:not(.f):not(.t):hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.legend { display: flex; gap: 16px; margin: 14px 4px 0; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border: 1px solid var(--ink); display: inline-block; position: relative; }
.lg.w { background: linear-gradient(to bottom, transparent 2px, var(--ink) 2px) 0 1px / 100% 3px repeat-y; background-clip: content-box; padding: 1px; }
.lg.p::after { content: ""; position: absolute; inset: 3px; background: var(--ink); }
.lg.t { background: var(--ink); }

/* ---- 한 달: 달력 ---- */
.mweek { display: grid; grid-template-columns: repeat(7, 1fr); padding: 10px 0 7px; }
.mweek span { font-family: var(--display); font-weight: 400; font-size: 10px; line-height: 1; padding-left: 6px; }
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--ink); border-left: 1px solid var(--ink); }
.mc {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  background: transparent; color: var(--ink); text-align: left;
}
.mc-d { position: absolute; left: 6px; top: 6px; font-family: var(--display); font-weight: 400; font-size: 11px; line-height: 1; }
.mc.w::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 6px; height: 10px; background: linear-gradient(to bottom, transparent 2px, currentColor 2px) 0 0 / 100% 3px repeat-y; }
.mc-p { position: absolute; right: 6px; top: 6px; width: 7px; height: 7px; background: currentColor; }
.mc.f { color: var(--ink-3); cursor: default; }
.mc.blank { cursor: default; }
.mc.t { background: var(--ink); color: var(--page-bg); }
.mc.sel:not(.t) { box-shadow: inset 0 0 0 2px var(--ink); }
.mc:not(.f):not(.t):not(.blank):hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }

/* ---- 그날의 글 (한 달 · 목록 공통) ---- */
.entry-main { display: flex; gap: 14px; align-items: flex-start; }
.entry-body { flex: 1; min-width: 0; }
.entry-text { font-size: 14px; font-weight: 600; line-height: 1.85; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.entry-empty { margin: 0; font-size: 14px; font-weight: 500; color: var(--ink-3); line-height: 1.85; }
.entry-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; font-weight: 500; line-height: 1.6; color: var(--ink-2); }
.entry-photo { flex: none; width: 68px; height: 68px; border: 0; padding: 0; overflow: hidden; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.entry-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.write-link {
  display: flex; align-items: center; gap: 6px; width: 100%; border: 0; text-align: left; color: var(--ink);
  font-size: 14px; font-weight: 500; padding: 16px 0 4px; margin-top: 20px;
  background: linear-gradient(to right, var(--ink) 55%, transparent 0) 0 0 / 9px 1px repeat-x;
}
.write-link span { font-size: 17px; font-weight: 300; line-height: 1; }
.month-entry { padding: 22px 4px 0; }
.month-entry .entry-text { cursor: pointer; }

/* ---- 목록 ---- */
.lfilter { display: flex; align-items: center; gap: 18px; padding: 14px 4px 14px; }
.radio { border: 0; background: none; padding: 4px 0; display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--ink); }
.radio i { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; }
.radio[aria-pressed="true"] i { background: var(--ink); }
.radio[aria-pressed="true"] i::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--page-bg); }
.lfilter .icon-btn { margin-right: -6px; }
.searchbar { display: flex; align-items: center; gap: 10px; margin: 0 4px 14px; border-bottom: 1.5px solid var(--ink); }
.searchbar input { flex: 1; min-width: 0; padding: 8px 0; border: 0; background: transparent; outline: none; font-size: 15px; font-weight: 600; }
.searchbar span { font-family: var(--display); font-size: 11px; }
.ltable { border-top: 1px solid var(--ink); border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); }
.lr { display: grid; grid-template-columns: 42px 1fr; border-bottom: 1px solid var(--ink); }
.lr-d { border-right: 1px solid var(--ink); padding: 20px 0 0 9px; font-family: var(--display); font-weight: 400; font-size: 12px; line-height: 1; }
.lr-d small { display: block; margin-top: 6px; font-size: 7px; letter-spacing: 0; }
.lr .entry { min-width: 0; padding: 18px 14px 0; }
.lr .write-link { width: calc(100% + 28px); margin: 18px -14px 0; padding: 15px 14px 15px; }
.lr.blank .lr-d { color: var(--ink-3); }
.lr.blank .entry { padding-top: 0; }
.lr.blank .entry-main, .lr.blank .entry-meta { display: none; }
.lr.blank .write-link { margin-top: 0; background: none; color: var(--ink-2); }
mark { background: var(--ink); color: var(--page-bg); padding: 0 2px; }
.empty { text-align: center; color: var(--ink-2); padding: 56px 12px; font-size: 14px; border-top: 1px solid var(--ink); margin: 0; }

/* ---- dock ---- */
.dock {
  flex: none; width: 100%; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 4px 14px calc(12px + env(safe-area-inset-bottom));
}
.dock-btn {
  width: 44px; height: 44px; border: 0; border-radius: 14px; background: transparent; color: color-mix(in srgb, var(--ink) 35%, transparent);
  display: grid; place-items: center; transition: color .15s, transform .15s; background-position: center; background-size: cover;
}
.dock-btn:hover { color: var(--ink); }
.dock-btn:active { transform: scale(.9); }
.dock-btn:disabled { opacity: .3; cursor: default; }
#btnPhoto { color: var(--ink); }
#btnPhoto.has-photo { width: 32px; height: 32px; margin: 6px; border-radius: 7px; box-shadow: 0 0 0 1.5px var(--ink); }
#btnPhoto.has-photo svg { display: none; }
body:not([data-mode="day"]) #btnPhoto { visibility: hidden; }

/* ---- sheets ---- */
.sheet {
  border: 0; padding: 0; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
.sheet[open] { animation: sheetIn .28s cubic-bezier(.2,.9,.3,1); }
@keyframes sheetIn { from { transform: translateY(14px) scale(.98); opacity: 0; } }
.sheet::backdrop { background: rgba(0,0,0,.3); backdrop-filter: blur(3px); }
.sheet form { padding: 22px 20px 18px; display: flex; flex-direction: column; gap: 16px; }
.sheet h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.03em; }
.photo-full { display: block; width: 100%; max-height: 62dvh; object-fit: contain; border-radius: 8px; background: var(--surface-2); }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sheet-actions { display: flex; gap: 8px; align-items: center; }
.btn { border: 0; background: var(--surface-2); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 700; transition: transform .15s; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.danger { color: var(--danger); background: transparent; padding-left: 4px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack .btn { text-align: left; }
.hint { font-size: 12px; font-weight: 400; color: var(--ink-2); margin: 0; line-height: 1.6; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; align-self: flex-start; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---- 계정 · 동기화 ---- */
.acct { display: flex; flex-direction: column; gap: 8px; }
.acct input {
  width: 100%; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink);
  font-size: 16px; font-weight: 500; outline: none;
}
.acct input:focus { box-shadow: inset 0 0 0 1.5px var(--ink); }
.acct-row { display: flex; align-items: center; gap: 8px; }
.acct-row .btn:disabled { opacity: .5; }
.acct-user { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px; }
.acct-user b { font-size: 15px; font-weight: 700; color: var(--ink); word-break: break-all; }
.acct-user small { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.acct-note { color: var(--ink); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.linkish { border: 0; background: none; padding: 4px 0; font-size: 12px; font-weight: 600; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost { background: transparent; color: var(--ink-2); }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--page-bg); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); animation: toastIn .28s cubic-bezier(.2,.9,.3,1);
}
@keyframes toastIn { from { transform: translate(-50%, 10px); opacity: 0; } }
.toast button { border: 0; background: none; color: inherit; text-decoration: underline; font-weight: 800; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
