/* 화면 공통 스타일 (D·F 시안). 값은 tokens.css 의 변수만 쓴다. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--paper); }
body {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh);
  letter-spacing: var(--tracking);
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }
button, input, textarea, select { font: inherit; color: var(--ink); }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.shell { position: relative; max-width: var(--page-max); min-height: 100dvh; margin: 0 auto; overflow-x: hidden; }
.page { position: relative; padding: 34px var(--page-x) calc(var(--tabbar-h) + 40px); }
.page.has-fab { padding-bottom: calc(var(--tabbar-h) + 100px); }
.page.no-tabs { padding-bottom: 48px; }

/* 배경 장식 삽화 (흐리게) */
.bg-illust { position: absolute; z-index: 0; pointer-events: none; opacity: .22; }
.page > *:not(.bg-illust) { position: relative; z-index: 1; }

/* ── 글자 위계 ── */
.hand { font-family: var(--font-hand); font-weight: 400; letter-spacing: .01em; }
.title { font-family: var(--font-hand); font-weight: 400; font-size: var(--fs-title); line-height: 1.12; letter-spacing: .01em; }
.label { font-size: var(--fs-xs); letter-spacing: .04em; color: var(--muted); }
.kicker { font-size: 12px; letter-spacing: .18em; color: var(--accent); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.hl-mint { background: var(--hl-mint); padding: 0 2px; }
.hl-peach { background: var(--hl-peach); padding: 0 2px; }
.hl-butter { background: var(--hl-butter); padding: 0 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.stack > * + * { margin-top: var(--s3); }

/* 쪽 머리: 왼쪽 구역, 오른쪽 구역장 + 아래 가는 선 */
.head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding-bottom: 10px; border-bottom: 1px solid var(--line); }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s5); border-radius: var(--r-pill);
  background: var(--mint); font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.btn.ghost { background: transparent; border: 1px solid var(--line); font-weight: 400; }
.btn.peach { background: var(--peach); }
.btn.block { width: 100%; min-height: 52px; font-size: var(--fs-md); }
.btn:disabled { opacity: .5; cursor: default; }
.pill { min-height: var(--tap); padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line); background: transparent; font-size: var(--fs-sm); }
.pill[aria-pressed="true"] { background: var(--mint); border-color: transparent; font-weight: 600; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.link-under { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 6px; font-size: var(--fs-sm); font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--peach); text-decoration-thickness: 3px; text-underline-offset: 6px; }

/* ── 1쪽: 초대장 대문 (D) ── */
.gate { margin-top: var(--s4); padding: 6px; border: 1px solid var(--frame); background: var(--card); }
.gate-in { border: 1px solid var(--frame-in); padding: 18px 18px 12px; text-align: center; }
.gate .date { margin-top: 10px; font-family: var(--font-hand); font-size: var(--fs-date); line-height: 1; letter-spacing: .01em; }
.gate .when { margin-top: 8px; font-size: var(--fs-lg); font-weight: 600; }
.gate .where { margin-top: 4px; font-size: 14px; color: var(--muted); }
.gate .house { display: block; margin: 14px auto 0; }

.meditate { margin-top: 22px; }
.meditate .hand { font-size: 21px; color: var(--accent); }
.meditate .verse { margin-top: 4px; font-size: var(--fs-md); line-height: 1.7; }

.line-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; width: 100%; text-align: left; }
.line-row b { font-weight: 600; }
.done-mark { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 6px; border-radius: 50%; background: var(--mint); vertical-align: -3px; }
.done-mark svg { width: 12px; height: 12px; }
.play { width: 34px; height: 34px; border-radius: 50%; background: var(--peach-soft); display: grid; place-items: center; flex: 0 0 auto; }
.play svg { width: 14px; height: 14px; }
.check { min-height: 36px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--card); font-size: var(--fs-xs); }
.check[aria-pressed="true"] { background: var(--mint); border-color: transparent; font-weight: 600; }

/* ── 2쪽: 기도 (F 메모지 + 전체는 D 목록) ── */
.tabs-line { display: flex; gap: 18px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.tabs-line button { min-height: var(--tap); padding: 0; font-size: var(--fs-sm); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-line button[aria-pressed="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

.notes { margin-top: 22px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.note { position: relative; display: flex; flex-direction: column; min-height: 176px; padding: 22px 14px 10px; box-shadow: var(--shadow-note); }
.note:nth-child(4n+1) { background: var(--mint-soft); transform: rotate(-1.2deg); }
.note:nth-child(4n+2) { background: var(--peach-soft); transform: rotate(1deg); }
.note:nth-child(4n+3) { background: var(--butter-soft); transform: rotate(.8deg); }
.note:nth-child(4n+4) { background: var(--white); transform: rotate(-.8deg); }
.note .meta { font-size: 12px; color: var(--muted); }
.note .text { margin-top: 6px; flex: 1; font-size: var(--fs-sm); line-height: 1.6; white-space: pre-wrap; }
.note .stamp { position: absolute; right: 8px; top: -14px; padding: 2px 8px; background: var(--butter); font-family: var(--font-hand); font-size: 16px; transform: rotate(4deg); }
.heart { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 0 10px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .7); font-size: var(--fs-xs); }
.heart[aria-pressed="true"] { background: var(--white); font-weight: 600; }
.heart svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 1.8; }
.heart[aria-pressed="true"] svg { fill: var(--ink); }

.plist { list-style: none; }
.plist li { display: grid; grid-template-columns: 34px minmax(0, 1fr) 52px; column-gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-hand); font-size: 19px; background: var(--mint-soft); }
.plist li:nth-child(3n+2) .avatar { background: var(--peach-soft); }
.plist li:nth-child(3n+3) .avatar { background: var(--butter-soft); }
.plist .meta { font-size: 14px; color: var(--muted); }
.plist .text { margin-top: 2px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; }
.pray-btn { width: 52px; height: 52px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: var(--fs-xs); }
.pray-btn[aria-pressed="true"] { background: var(--mint); border-color: transparent; font-weight: 600; }
.pray-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.8; }
.pray-btn[aria-pressed="true"] svg { fill: var(--ink); }
.mine-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.mine-tools button { font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; min-height: 28px; }

.add-note {
  position: fixed; z-index: 21; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px);
  width: calc(min(100%, var(--page-max)) - 2 * var(--page-x));
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px;
  border-radius: var(--r-pill); border: 1.5px dashed #C9B49A; background: var(--card); box-shadow: var(--shadow-note);
  font-family: var(--font-hand); font-size: 22px;
}

/* 공지·일정 목록 */
.list { list-style: none; }
.list li { padding: var(--s4) 0; border-bottom: 1px solid var(--line-soft); }
.list .when { font-family: var(--font-hand); font-size: 24px; line-height: 1.1; color: var(--accent); }
.empty { padding: var(--s8) 0; text-align: center; font-size: var(--fs-sm); color: var(--muted); }

/* ── 아래 탭 바 ── */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 20;
  width: 100%; max-width: var(--page-max);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 8px 8px max(18px, env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; text-decoration: none; font-size: var(--fs-xs); color: var(--muted); }
.tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabbar a[aria-current="page"] svg { fill: var(--mint); }

/* ── 창·안내 ── */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(58, 53, 48, .4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: var(--page-max); max-height: 90dvh; overflow-y: auto; background: var(--paper); border-radius: 20px 20px 0 0; padding: var(--s6) var(--page-x) max(24px, env(safe-area-inset-bottom)); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabbar-h) + 84px); transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 10px 18px; font-size: var(--fs-sm); box-shadow: var(--shadow); max-width: 90%; }
.frame { border: 1px solid var(--line); border-radius: 4px; padding: var(--s4); background: var(--card); }

/* ── 입력칸 (메일 폼·관리자·로그인) ── */
.field { display: block; margin-top: var(--s4); }
.field > span { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--s1); }
.input, textarea.input, select.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); font-size: var(--fs-md); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.code-box { text-align: center; padding: var(--s4); border: 1px dashed var(--frame); border-radius: var(--r-sm); background: var(--card); }
.code-box .code { font-size: 34px; font-weight: 700; letter-spacing: 6px; color: var(--accent); }
.list-edit .item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) 40px; gap: var(--s2); margin-top: var(--s2); }
.list-edit .item.song { grid-template-columns: minmax(0, 1fr) 40px; }
.list-edit .item .url { grid-column: 1 / -1; }
.del { width: 40px; min-height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card); }
.history { list-style: none; margin-top: var(--s3); }
.history li { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl th { font-weight: 600; }
.scroll-x { overflow-x: auto; }
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--s4); }

/* ── 관리자 (폰 중심 · PC 에서는 가운데 720px, 카드 2열) ── */
.admin-wrap { max-width: 720px; margin: 0 auto; }
.admin-top { position: sticky; top: 0; z-index: 10; background: var(--paper); padding: 16px 20px 0; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--card); font-size: var(--fs-sm); white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.admin-body { padding: 18px 20px 60px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.group-h { font-family: var(--font-hand); font-weight: 400; font-size: 24px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.cards { list-style: none; display: grid; gap: 8px; margin-top: 10px; }
.mcard { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) 20px; align-items: center; gap: 12px; min-height: 64px; padding: 10px 12px; text-align: left; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--r-md); }
.mcard-main { display: flex; flex-direction: column; gap: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--line-soft); }
.badge.mint { background: var(--mint); } .badge.peach { background: var(--peach); } .badge.butter { background: var(--butter); }
.badge.ink { background: var(--ink); color: var(--paper); }
.pcard { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px 14px; }
.pcard.gone { opacity: .6; }
.att-list { list-style: none; margin-top: 12px; }
.att-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.att-btns { display: flex; gap: 6px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.action-list { display: grid; gap: 8px; margin-top: 16px; }
.qr-box { background: var(--white); padding: 12px; display: inline-block; margin-top: 12px; }
@media (min-width: 700px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-top, .admin-body { padding-left: 0; padding-right: 0; }
  .sheet { border-radius: 20px; margin-bottom: 5vh; max-width: 480px; }
  .sheet-back { align-items: center; }
}

/* ── 구분 삽화 (js/illustrations.js 라이브러리, 주보와 같은 그림) ──
   wide = 내용 폭 그대로 가로 장면, spot = 가운데 작은 한 컷. 글을 가리지 않고 화면 읽기에서는 숨김 */
.doodle { margin: 32px auto 0; width: 120px; max-width: 60%; }
.doodle[data-kind="wide"] { width: 100%; max-width: none; margin-top: 40px; }
.doodle svg { display: block; width: 100%; height: auto; overflow: visible; }

/* 홈 화면에 추가 안내 (install.js) */
.install-steps { margin-top: var(--s3, 12px); padding-left: 1.3em; display: grid; gap: 8px; font-size: var(--fs-sm, 15px); line-height: 1.6; }
.install-steps b { font-weight: 600; }
