:root { --bg: #fff8ec; --ink: #3b3024; --muted: #8a7a66; --card: #fff; --line: #ecdfc8; --accent: #e8633a; --accent-dark: #b9471f; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
.top { position: sticky; top: 0; z-index: 5; background: rgba(255,248,236,.95); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 1.25rem; }
main { max-width: 640px; margin: 0 auto; padding: 12px 12px 80px; }
button { font: inherit; border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer; background: #fff; color: var(--ink); box-shadow: 0 2px 0 var(--line); }
button.primary { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); font-weight: 800; }
button.ghost { background: transparent; box-shadow: none; color: var(--muted); }
button.link { background: none; box-shadow: none; padding: 0; color: var(--accent-dark); font-size: .85rem; text-decoration: underline; }
button.link.danger { color: #b33; }
button:disabled { opacity: .6; cursor: default; }
.stats { display: flex; gap: 8px; margin-bottom: 12px; }
.stat { flex: 1; background: var(--card); border-radius: 14px; padding: 10px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.stat b { display: block; font-size: 1.4rem; }
.stat small { color: var(--muted); font-size: .75rem; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.entry { background: var(--card); border-radius: 18px; overflow: hidden; margin-bottom: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.photos { display: grid; gap: 2px; position: relative; background: #f3ead9; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; aspect-ratio: 4 / 3; }
.photos.n1 { grid-template-columns: 1fr; }
.photos.n2 { grid-template-columns: 1fr 1fr; }
.photos.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.photos.n3 img:first-child { grid-row: 1 / 3; aspect-ratio: auto; }
.photos.n4 { grid-template-columns: 1fr 1fr; }
.photos img:nth-child(n+5) { display: none; }
.photos .more { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; }
.body { padding: 12px 14px 14px; }
.date { color: var(--muted); font-size: .8rem; }
.title { margin: 2px 0 6px; font-size: 1.15rem; }
.kcal { background: #fff3e4; border-radius: 10px; padding: 8px 10px; margin: 6px 0 8px; font-size: .95rem; }
.kcal small { color: var(--muted); }
.kcal.err { background: #fde8e8; color: #933; }
.kcal-items { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kcal-tools { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.memo { white-space: normal; line-height: 1.5; font-size: .95rem; }
.placeholder { color: #bbb; }
.tools { margin-top: 8px; color: var(--muted); font-size: .8rem; }
dialog { border: 0; border-radius: 18px; padding: 18px 16px; width: min(92vw, 480px); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin: 0 0 10px; font-size: 1.1rem; }
dialog label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
dialog label small { font-weight: 400; }
dialog input[type=text], dialog input[type=date], dialog input[type=password], dialog textarea {
  width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; color: var(--ink); background: #fff; }
dialog input[type=file] { display: block; margin-top: 4px; font-size: .9rem; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.preview { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.msg { color: #b33; font-size: .85rem; min-height: 1.2em; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#lightbox { padding: 0; background: #000; width: min(96vw, 900px); }
#lightbox img { width: 100%; height: auto; display: block; max-height: 88vh; object-fit: contain; }
#lightbox .close { position: absolute; top: 8px; right: 8px; color: #fff; background: rgba(0,0,0,.5); }
@media (max-width: 600px) {
  .top { padding: 10px 12px; }
  h1 { font-size: 1.1rem; }
  button.primary { padding: 9px 14px; font-size: .95rem; }
  main { padding: 10px 8px 80px; }
  .body { padding: 10px 12px 12px; }
}

.top-actions { display: flex; gap: 6px; }
.top-actions button { white-space: nowrap; }
.photo-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ghost-label { display: inline-block; padding: 10px 16px; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: .95rem; }
.photo-btns .ghost { font-size: .95rem; }
.preview .thumb { position: relative; display: inline-block; }
.preview .x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: #3b3024; color: #fff; font-size: 14px; line-height: 22px; box-shadow: none; }
@media (max-width: 600px) {
  .top-actions button { padding: 9px 11px; font-size: .9rem; }
  h1 { font-size: 1rem; }
}

/* 숨긴 입력은 항상 숨긴다 (dialog input[type=file] 규칙보다 우선) */
input[hidden] { display: none !important; }
.top h1 { white-space: nowrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #ddd; vertical-align: middle; }
.dot.r.on, .cal-legend .dot.r, .meal-pick .dot.r, .meal-tag .dot.r { background: #e8453c; }
.dot.y.on, .cal-legend .dot.y, .meal-pick .dot.y, .meal-tag .dot.y { background: #f5b400; }
.dot.g.on, .cal-legend .dot.g, .meal-pick .dot.g, .meal-tag .dot.g { background: #2eaa5a; }
.dot.s.on, .cal-legend .dot.s, .meal-pick .dot.s, .meal-tag .dot.s { background: #7b61ff; }
.meal-pick { display: flex; gap: 6px; margin: 8px 0 2px; }
.meal-pick label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; margin: 0; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-size: .9rem; cursor: pointer; }
.meal-pick input { display: none; }
.meal-pick label:has(input:checked) { background: #fff3e4; border-color: var(--accent); font-weight: 700; }
.cal-wrap { background: var(--card); border-radius: 16px; padding: 10px 10px 8px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head h2 { margin: 0; font-size: 1rem; }
.cal-head .ghost { font-size: 1.3rem; padding: 2px 14px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal .wd { text-align: center; font-size: .7rem; color: var(--muted); padding: 2px 0 4px; }
.cal .wd.sun { color: #c33; } .cal .wd.sat { color: #36c; }
.cal .day { aspect-ratio: 1 / 1.05; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .8rem; color: var(--ink); background: transparent; border: 0; padding: 0; box-shadow: none; }
.cal .day.has { background: #fff8ec; }
.cal .day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal .day.sel { background: #ffe3d2; }
.cal .day.empty { visibility: hidden; }
.cal .day .dots { display: flex; gap: 3px; height: 8px; }
.cal .day .dot { width: 7px; height: 7px; }
.cal-legend { display: flex; gap: 10px; justify-content: center; align-items: center; font-size: .72rem; color: var(--muted); margin-top: 6px; }
.cal-legend .dot { margin-right: 3px; }
.cal-filter { text-align: center; font-size: .85rem; margin-top: 6px; }
.cal-filter:empty { display: none; }
.entry .meal-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--muted); margin-left: 6px; }
@media (max-width: 600px) {
  #newBtn .t { display: none; }
  #newBtn { padding: 9px 12px; }
  .top h1 { font-size: 1rem; }
}
