/* ==========================================================
 * 오늘의 서신 - 크래프트지 + 손글씨 테마
 * ========================================================== */

:root {
  /* 베이스 톤 #e5e6e3 — 차분한 무채색 (노란기 제거) */
  --kraft-base:  #e5e6e3;
  --kraft-light: #f0f1ee;
  --kraft-dark:  #b6b7b3;
  --ink:        #28282a;
  --ink-soft:   #4a4a4c;
  --rule:       #7c7c7e;
  --accent-red:   #b13b34;
  --accent-blue:  #4a6790;
  --accent-green: #6e8a5a;
  --shadow: 0 6px 18px rgba(40, 40, 42, 0.14);
  /* 종이 박스/입력 위에 깔리는 옅은 흰끼 — 무채색 */
  --paper-tint:    rgba(248, 248, 246, 0.55);
  --paper-tint-2:  rgba(248, 248, 246, 0.7);
  --paper-tint-3:  rgba(248, 248, 246, 0.92);
  --max-w: 760px;
  /* 시스템 기본 폰트 — 커스텀 패밀리 모두 제거. (에디터 안에서 사용자가 고른 폰트는 inline style 로 그대로 살아남음) */
  --hand:      system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
  --hand-soft: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
  --hand-cute: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
}

/* 종이 텍스처 — base #e5e6e3 위에 사진 luminosity blend 로 결만 살림.
   `body::before { position: fixed }` 별도 레이어로 두는 이유: iOS Safari 등 일부 모바일이
   `background-attachment: fixed` 를 무시해 스크롤 시 배경이 따라 올라가던 문제 회피. */
html {
  background-color: #e5e6e3;   /* overscroll 영역 색 */
}
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 18px;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-color: var(--theme-bg, #e5e6e3);
  background-image: var(--theme-bg-image, url('/images/paper-bg.jpg'));
  background-repeat: repeat;
  background-size: 600px auto;
  background-blend-mode: luminosity;
  z-index: -1;
  pointer-events: none;
}

html { scroll-behavior: smooth; }

a { color: inherit; text-decoration: none; }
a:hover {
  text-decoration: none;
  border-bottom: 1.5px solid currentColor;
}
button { font-family: inherit; }
.link-btn:hover,
.nav-btn:hover { border-bottom: 1.5px solid currentColor; }
/* 카드/원형 버튼은 hover 밑줄을 빼고 배경 톤만 변화 */
.card-link:hover,
.cal-link:hover,
.fab a:hover,
.fab summary:hover { border-bottom: 0; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 12px;
  max-width: var(--max-w);
  margin: 0 auto;
  border-bottom: 1px solid rgba(70, 70, 72, 0.4);
}
.brand {
  font-family: var(--hand-soft);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 18px;
}
.nav a {
  color: var(--ink-soft);
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.nav a.active {
  color: var(--ink);
  border-bottom-color: var(--rule);
}
.logout-form { margin: 0; }
.link-btn {
  background: none;
  border: 0;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  font-size: inherit;
}

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 6px 64px;
}
/* 사용자 페이지 — FAB 가 펼쳤을 때(가이드 + 나눔 + 서브메뉴 펼친 상태) viewport
   하단에서 약 380px 차지. 댓글/공감 버튼이 FAB 에 가려지지 않도록 padding-bottom 확보. */
body.is-user .page { padding-bottom: 380px; }

/* 종이 카드: 종이 위 종이 느낌이 너무 강하지 않게 — 얇은 외곽선만 */
.paper {
  position: relative;
  padding: 0 8px 32px;
}
.paper + .paper { margin-top: 18px; }

.muted { color: var(--ink-soft); opacity: 0.8; }
.small { font-size: 16px; }
.hand { font-family: var(--hand-soft); font-weight: 700; font-size: 28px; margin: 0 0 12px; }

/* ===== 서신 카드 ===== */
.letter-head {
  display: flex;
  align-items: baseline;
  gap: 6px 14px;
  flex-wrap: wrap;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
/* 제목까지 포함한 헤더 — 아래에 줄(구분선) */
.letter-head--titled {
  border-bottom: 1px solid rgba(70, 70, 72, 0.4);
  padding-bottom: 12px;
  margin-bottom: 18px;
  /* 좌측 정렬: 제목 → 태그 → 날짜 위에서 아래로 쌓임 */
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  text-align: left;
}
.letter-head--titled .letter-title {
  margin: 0;
  text-align: left;
  width: 100%;
}
.letter-head--titled .tags {
  margin: 0;
  justify-content: flex-start;
}
.letter-head--titled .date-stamp {
  display: block;
  text-align: left;
}
/* 메인 화면: 날짜 숨김 */
.letter-head--main .date-stamp { display: none; }

/* ===== 상세 화면 — 헤더 위에 별도 날짜 라인 =====
   헤더 자체는 메인(letter-head--main) 과 동일하게 제목 풀폭 + 태그 stack */
.letter-date-line {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 8px;
}
.letter-date-line .date-stamp {
  font-size: 12px;
  white-space: nowrap;
  color: var(--ink-soft);
}
/* 브랜드 + 날짜 한 줄 — 메인/상세 동일 위치(우상단) */
.letter-date-line .letter-brand-date {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.date-stamp {
  font-family: var(--hand-cute);
  color: var(--ink-soft);
  font-size: 18px;
  letter-spacing: 0.03em;
}
.letter-title {
  font-family: var(--hand-soft);
  font-size: 18px;
  margin: 8px 0 4px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.letter-body {
  white-space: normal;
  word-break: keep-all;
  font-size: 19px;
  line-height: 1.85;
}
.letter-body p { margin: 0; padding: 0; }
.letter-body img {
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 2px;
}
/* 에디터에서 지정한 폰트/사이즈/색을 그대로 살리기 위해 본문 영역은 inline 스타일을 우선시 */
.letter-body--rich { font-family: inherit; }
.letter-body--rich .ql-font-serif    { font-family: Georgia, "Times New Roman", serif; }
.letter-body--rich .ql-font-monospace { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Quill 의 정렬/들여쓰기 클래스 — 사용자 화면에선 quill.snow.css 를 안 부르므로 직접 정의 */
.letter-body--rich .ql-align-center  { text-align: center; }
.letter-body--rich .ql-align-right   { text-align: right; }
.letter-body--rich .ql-align-justify { text-align: justify; }
.letter-body--rich .ql-indent-1 { padding-left: 3em; }
.letter-body--rich .ql-indent-2 { padding-left: 6em; }
.letter-body--rich .ql-indent-3 { padding-left: 9em; }
.letter-body--rich .ql-indent-4 { padding-left: 12em; }
.letter-body--rich .ql-indent-5 { padding-left: 15em; }
.letter-body--rich .ql-indent-6 { padding-left: 18em; }
.letter-body--rich .ql-indent-7 { padding-left: 21em; }
.letter-body--rich .ql-indent-8 { padding-left: 24em; }
.letter-body--rich blockquote {
  border-left: 4px solid rgba(70, 70, 72, 0.4);
  padding-left: 14px;
  margin: 12px 0;
  color: var(--ink-soft);
}
.letter-body--rich img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 0;
  margin: 6px 0 0;
  font-family: var(--hand-cute);
  color: var(--ink-soft);
  font-size: 17px;
}
.tags li::before { content: ""; }
.tags.small { font-size: 15px; }

.verse {
  margin-top: 22px;
  padding: 12px 14px;
  border-left: 3px solid var(--rule);
  background: rgba(248, 248, 246, 0.35);
}
.verse-top {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--rule);
  background: rgba(248, 248, 246, 0.45);
}
.verse-text { margin: 0; }
.verse-ref { margin: 0 0 6px; font-size: 16px; color: var(--ink-soft); font-weight: 700; }
/* "오늘의 한 절 말씀" 소제목 — verse-top 상단 */
.verse-section-title {
  margin: 0 0 8px;
  font-family: var(--hand-soft);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* 기도문 — 본문 아래에 verse 와 같은 톤. 줄바꿈 보존. */
.verse-prayer { margin-top: 22px; }
.prayer-text { white-space: pre-wrap; word-break: keep-all; }

.empty { padding: 40px 0; text-align: center; }

.card-actions {
  display: flex;
  gap: 16px;
  margin-top: 22px;
  font-family: var(--hand-cute);
}
.back {
  font-family: var(--hand-cute);
  color: var(--ink-soft);
}

/* ===== 캘린더 ===== */
.calendar-card { padding: 0; }
.calendar { font-family: var(--hand); }
.admin-cal-help { margin: 0 0 4px; }
.cal-legend-row { display: flex; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-divider {
  border: 0;
  border-top: 1px solid rgba(70, 70, 72, 0.3);
  margin: 18px 0 8px;
}
.month-letters { margin-top: 4px; }
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-title {
  font-family: var(--hand-soft);
  font-weight: 700;
  font-size: 26px;
  margin: 0;
}
.nav-btn {
  background: transparent;
  border: 1.5px solid rgba(70, 70, 72, 0.45);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  font-family: var(--hand);
  transition: background 150ms ease, transform 120ms ease, border-color 150ms ease;
}
.nav-btn:hover { background: rgba(248, 248, 246, 0.5); border-color: var(--ink); }
.nav-btn:active { transform: scale(0.94); }
.nav-btn[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}
.nav-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2.6;          /* 두꺼운 화살표 */
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

.cal-dow {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0;
  margin: 0 0 6px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 16px;
}
.cal-dow li:first-child { color: var(--accent-red); }
.cal-dow li:last-child { color: var(--accent-blue); }

.cal-days {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0;
  margin: 0;
  gap: 2px 0;
}
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  position: relative;
}
.cal-link:hover { text-decoration: none; background: rgba(70, 70, 72, 0.06); }
.cal-day-number {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--ink);
}
.cal-cell.out .cal-day-number { color: rgba(70, 70, 72, 0.3); }
.cal-cell:nth-child(7n+1) .cal-day-number { color: var(--accent-red); }
.cal-cell:nth-child(7n) .cal-day-number { color: var(--accent-blue); }
.cal-cell.out:nth-child(7n+1) .cal-day-number,
.cal-cell.out:nth-child(7n) .cal-day-number { color: rgba(70, 70, 72, 0.3); }
/* 사용자 모드: 서신 없는 날짜는 흐리게 (요일 색상도 함께 약화) */
body.is-user .cal-cell:not(.has-letter):not(.today):not(.out) .cal-day-number,
body.is-user .cal-cell:not(.has-letter):not(.today):not(.out):nth-child(7n+1) .cal-day-number,
body.is-user .cal-cell:not(.has-letter):not(.today):not(.out):nth-child(7n) .cal-day-number {
  color: rgba(70, 70, 72, 0.4);
}

/* 오늘: 연필로 슥슥 그린 손글씨 동그라미 — SVG (두 번 겹친 path) 로 들쭉날쭉한 라인 */
.cal-cell.today::before {
  content: "";
  position: absolute;
  inset: 10% 10%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='none' stroke='%23b13b34' stroke-linecap='round' stroke-linejoin='round'><path d='M50 8 C 78 7 92 27 93 50 C 94 76 71 93 49 92 C 23 94 6 73 8 49 C 6 24 26 6 52 9' stroke-width='2.4' opacity='0.95'/><path d='M52 11 C 76 10 89 30 90 51 C 91 75 69 89 50 90 C 27 90 10 70 11 51 C 9 27 30 11 53 11' stroke-width='1.8' opacity='0.55'/></g></svg>");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transform: rotate(-4deg);
  pointer-events: none;
  z-index: 0;
}
/* 발행된 날짜: 셀 옅은 빨강 워터마크 + 우상단 손글씨 실선 밑줄 */
.cal-cell.has-letter {
  background: rgba(177, 59, 52, 0.07);
  border-radius: 8px;
}
.cal-cell.has-letter::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% + 14px);
  transform: translateX(-50%);
  width: 26px;
  height: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 20 1, 40 4 T 80 4 T 118 4' stroke='%23b13b34' stroke-width='1.6' fill='none' stroke-linecap='round'/><path d='M3 4.6 Q 22 2, 42 4.4 T 82 4.4 T 117 4.2' stroke='%23b13b34' stroke-width='1' fill='none' stroke-linecap='round' opacity='0.5'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}
/* 임시저장만 있는 날짜: 셀 옅은 회색 + 우상단 손글씨 점선 밑줄 */
.cal-cell.has-draft:not(.has-letter) {
  background: rgba(70, 70, 72, 0.07);
  border-radius: 8px;
}
.cal-cell.has-draft:not(.has-letter)::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% + 14px);
  transform: translateX(-50%);
  width: 26px;
  height: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 8 2, 14 4 T 26 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M32 4 Q 38 2, 44 4 T 56 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M62 4 Q 68 2, 74 4 T 86 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M92 4 Q 98 2, 104 4 T 116 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}
/* 오늘+발행: 오늘 동그라미와 겹치지 않게 셀 하단으로 */
.cal-cell.today.has-letter::after {
  content: "";
  position: absolute;
  left: 50%;
  top: auto;
  bottom: 4%;
  transform: translateX(-50%);
  width: 26px;
  height: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 20 1, 40 4 T 80 4 T 118 4' stroke='%23b13b34' stroke-width='1.6' fill='none' stroke-linecap='round'/><path d='M3 4.6 Q 22 2, 42 4.4 T 82 4.4 T 117 4.2' stroke='%23b13b34' stroke-width='1' fill='none' stroke-linecap='round' opacity='0.5'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}
.cal-cell.today.has-draft:not(.has-letter)::after {
  top: auto;
  bottom: 4%;
  width: 26px;
  height: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 8 2, 14 4 T 26 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M32 4 Q 38 2, 44 4 T 56 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M62 4 Q 68 2, 74 4 T 86 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M92 4 Q 98 2, 104 4 T 116 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}
.cal-cell .cal-link,
.cal-cell .cal-day-number { position: relative; z-index: 1; }

/* ===== 상단 타이틀 줄 ===== */
.list-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.list-top h1 { margin: 0; }
.list-hint {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  opacity: 0.85;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(70, 70, 72, 0.25);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  color: var(--ink);
  background: transparent;
}
.pill:hover { text-decoration: none; background: rgba(70, 70, 72, 0.06); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-ico { width: 16px; height: 16px; vertical-align: -3px; margin-right: 5px; }

/* 글쓰기 플로팅 버튼(우측 하단, 연필 아이콘만) */
.fab-write {
  position: fixed;
  right: 20px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  width: 58px; height: 58px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  color: var(--kraft-light);
  border: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  z-index: 90;
  cursor: pointer;
}
.fab-write:hover { background: var(--ink-soft); text-decoration: none; }
.fab-write svg { width: 26px; height: 26px; }

/* 상세 하단 플로팅 이동/관리 바 (‹ 이전 · 목록 · 수정 · 삭제 · 다음 ›) — 전부 아이콘 */
.detail-fab {
  position: fixed;
  left: 12px; right: 12px; margin: 0 auto; max-width: 440px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  background: var(--ink);
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  z-index: 90;
}
.detail-fab-row { display: flex; align-items: center; justify-content: space-evenly; gap: 6px; }
.detail-fab-btn {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  color: var(--kraft-light);
  background: transparent; border: 0;
}
.detail-fab-btn:hover { background: rgba(255, 255, 255, 0.14); text-decoration: none; }
.detail-fab-btn.is-disabled { opacity: 0.28; }
.detail-fab-btn svg { width: 23px; height: 23px; }
.detail-fab-btn.center svg { width: 25px; height: 25px; }
.detail-fab-btn--label { width: auto; height: 42px; padding: 0 14px; gap: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.10); }
.detail-fab-btn--label:hover { background: rgba(255, 255, 255, 0.2); }
.detail-fab-btn--label span { font-size: 15px; font-weight: 600; }
.detail-fab-btn--label svg { width: 18px; height: 18px; }
.detail-fab form { display: contents; }                 /* 삭제 폼이 FAB flex 레이아웃을 깨지 않게 */
.detail-fab-btn--save { background: rgba(255, 255, 255, 0.16); }
.detail-fab-btn--save:hover { background: rgba(255, 255, 255, 0.28); }
.detail-fab-btn--danger { color: #f2a29a; order: -1; }   /* 삭제는 항상 맨 왼쪽(DOM 순서는 유지 → Enter 제출은 저장이 기본) */
.detail-fab-btn--danger:hover { background: rgba(242, 162, 154, 0.18); }

/* 등록·수정 화면 하단 플로팅 버튼바(라벨형) */
.form-fab {
  position: fixed;
  left: 12px; right: 12px; margin: 0 auto; max-width: 440px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; justify-content: space-evenly; gap: 4px;
  background: var(--ink);
  border-radius: 20px;                 /* 999px(원) 금지 — 줄바꿈되면 원이 되므로 둥근 사각 패널로 */
  padding: 7px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  z-index: 90;
}

/* 수정화면: 미리보기 아래 버튼들을 상세 바(알약)와 같은 스타일로 (버튼은 .detail-fab-btn 재사용) */
.edit-bar {
  display: inline-flex; align-items: center; gap: 2px;
  margin-top: 14px;
  background: var(--ink);
  border-radius: 999px;
  padding: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* 메모 없는 날 */
.day-empty .empty-msg { color: var(--ink-soft); font-size: 18px; margin: 18px 0 22px; }

/* 이미지로 저장(다운로드) 메뉴 */
.dl-menu { position: relative; display: inline-flex; }
.dl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(248, 248, 246, 0.85); border: 1px solid rgba(70, 70, 72, 0.25);
  color: var(--ink-soft); cursor: pointer;
}
.dl-btn:hover { background: rgba(70, 70, 72, 0.08); }
.dl-btn svg { width: 18px; height: 18px; }
.dl-options {
  display: none;
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #f5f4f0; border: 1px solid rgba(70, 70, 72, 0.22);
  border-radius: 10px; padding: 6px; min-width: 132px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18); z-index: 60;
}
.dl-menu.is-open .dl-options { display: block; }
.dl-options-label { display: block; padding: 4px 10px 6px; font-size: 12px; color: var(--ink-soft); opacity: 0.8; }
.dl-options a { display: block; padding: 9px 12px; border-radius: 7px; color: var(--ink); font-size: 15px; white-space: nowrap; }
.dl-options a:hover { background: rgba(70, 70, 72, 0.08); text-decoration: none; }

/* 카드: 우측 하단(썸네일과 겹치지 않게) */
.card { position: relative; }
.card > .dl-btn { position: absolute; bottom: 10px; right: 10px; z-index: 3; width: 34px; height: 34px; }
.card > .dl-btn svg { width: 16px; height: 16px; }

/* 상세: 우측 상단 */
.note-detail { position: relative; }
.note-detail > .dl-btn { position: absolute; top: 16px; right: 16px; }

/* 상세 본문 — 에디터와 개행/여백 대체로 맞춤 */
.detail-meta { display: flex; gap: 10px; align-items: center; margin: 6px 0 10px; }
.detail-title { font-family: var(--hand); font-weight: 700; font-size: 34px; line-height: 1.3; color: var(--ink); margin: 0 0 22px; }
.detail-body { font-size: 17px; line-height: 1.5; color: var(--ink); word-break: break-word; }
.detail-body p { margin: 0; min-height: 1.5em; }
.detail-body img { max-width: 100%; height: auto; border-radius: 6px; }
.detail-admin { display: flex; gap: 8px; align-items: center; margin-top: 30px; padding-top: 18px; border-top: 1px solid rgba(70, 70, 72, 0.15); }
.detail-admin form { display: inline; margin: 0; }
button.pill { cursor: pointer; }
.pill-danger { color: var(--accent-red); border-color: rgba(177, 59, 52, 0.4); }
.pill-danger:hover { background: rgba(177, 59, 52, 0.08); }

/* ===== 아카이브 사진 ===== */
.photo-archive { margin-top: 26px; }
.photo-archive-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.photo-archive-head > span:first-child { font-family: var(--hand-cute); font-size: 16px; color: var(--ink-soft); }
.photo-archive-hint { font-size: 12px; color: var(--ink-soft); opacity: 0.7; }
.photo-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: rgba(70, 70, 72, 0.08); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 16px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.photo-del:hover { background: rgba(0, 0, 0, 0.78); }
.photo-add {
  aspect-ratio: 1 / 1; border-radius: 8px; border: 1.5px dashed rgba(70, 70, 72, 0.35);
  background: transparent; color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-add:hover { background: rgba(70, 70, 72, 0.05); }
.photo-add svg { width: 26px; height: 26px; }
.photo-add:disabled { opacity: 0.5; cursor: default; }

/* 카드 사진 장수 배지 */
.card-meta-row { display: flex; align-items: center; gap: 10px; }
.card-photos { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--ink-soft); }
.card-photos svg { width: 13px; height: 13px; }

/* ===== 글쓰기 비밀번호 모달 ===== */
.write-modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200; padding: 20px;
}
.write-modal.is-open { display: flex; }
.write-modal-card {
  background: #f4f3ef;
  border: 1px solid rgba(70, 70, 72, 0.3);
  border-radius: 10px;
  padding: 22px 20px;
  width: 100%; max-width: 320px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.28);
}
.write-modal-card h2 { margin: 0 0 14px; text-align: center; }
.write-modal-form { display: flex; flex-direction: column; gap: 12px; }
.write-modal-form input[type="password"] {
  font-family: var(--hand); font-size: 20px;
  padding: 10px 12px; text-align: center; letter-spacing: 4px;
  background: rgba(248, 248, 246, 0.7);
  border: 1px solid rgba(70, 70, 72, 0.4); border-radius: 6px; color: var(--ink);
  box-sizing: border-box; width: 100%;
}
.write-modal-actions { display: flex; gap: 10px; }
.write-modal-actions .primary,
.write-modal-actions .secondary { flex: 1; }

/* 에디터 하단 버튼 줄 */
.editor-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.editor-actions .spacer { flex: 1; }

/* 검색만 있는 필터(분류 select 제거 후) */
.list-filter.list-filter--simple { grid-template-columns: 1fr auto; }

/* ===== 목록 ===== */
.list-filter {
  display: grid;
  grid-template-columns: 1fr 140px 130px;
  gap: 10px;
  margin-bottom: 18px;
}
.list-filter input,
.list-filter select {
  font-family: var(--hand);
  font-size: 17px;
  background: rgba(248, 248, 246, 0.5);
  border: 1px solid rgba(70, 70, 72, 0.35);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--ink);
  box-sizing: border-box;
  width: 100%;
}
.list-filter input.combo-input,
.list-filter select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a3f30' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
/* 데이트리스트 input 의 네이티브 화살표 숨김 (브라우저별 다름) */
input::-webkit-calendar-picker-indicator { opacity: 0; }
input.combo-input::-webkit-calendar-picker-indicator { opacity: 0; }
@media (max-width: 560px) {
  .list-filter { grid-template-columns: 1fr 1fr; }
  /* 검색 인풋만 전체 폭, tag/sort 콤보는 같은 줄에 나란히 */
  .list-filter input[name='q'] { grid-column: 1 / -1; }
}

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.card {
  padding: 18px 8px 20px;
}
.card-list > .card + .card {
  border-top: 1px solid rgba(70, 70, 72, 0.35);
}
.card-link {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "title   date"
    "tags    .   "
    "snippet thumb";
  column-gap: 14px;
  row-gap: 6px;
  align-items: start;
}
.card-link:hover { text-decoration: none; }

/* 짝수번째 카드 — 썸네일을 왼쪽으로, 본문은 오른쪽으로 (단, 썸네일 있을 때만) */
.card-list > .card:nth-child(even) .card-link:not(.no-thumb) {
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "title   date"
    "tags    .   "
    "thumb   snippet";
}

/* 썸네일이 없는 카드 — thumb 칼럼 제거, 본문이 두 컬럼 차지 (짝/홀 무관) */
.card-link.no-thumb {
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title   date"
    "tags    .   "
    "snippet snippet";
}

.card-title {
  grid-area: title;
  font-family: var(--hand-soft);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}
.card-date {
  grid-area: date;
  font-size: 14px;
  white-space: nowrap;
  align-self: start;
  text-align: right;
  justify-self: end;
}
.card-tags {
  grid-area: tags;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--ink-soft);
}
.card-snippet {
  grid-area: snippet;
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.55;
  /* 본문 최대 5줄 — 썸네일이 작아진 만큼 본문을 더 노출 */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  align-self: start;
}
.card-thumb {
  grid-area: thumb;
  width: 72px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  margin: 0;
  border: 1px solid rgba(70, 70, 72, 0.25);
  align-self: start;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pager {
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: center;
  margin-top: 22px;
  font-family: var(--hand-cute);
}
.pg-info { color: var(--ink-soft); }

/* ===== 더보기(무한스크롤) ===== */
.load-more {
  list-style: none;
  display: flex;
  justify-content: center;
  padding: 24px 0 4px;
}
.btn-more {
  font-family: var(--hand-cute);
  font-size: 16px;
  padding: 11px 32px;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-more:hover { background: var(--ink); color: var(--kraft-light); border-color: var(--ink); }
.load-more.htmx-request { pointer-events: none; }
.load-more.htmx-request .btn-more { opacity: .55; }
.load-more.htmx-request .btn-more::after { content: " …"; }

/* ===== 관리자 로그인/에디터 ===== */
.login-card { max-width: 380px; margin: 60px auto; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.login-form label { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.login-form input[type="password"] {
  font-family: var(--hand);
  font-size: 18px;
  padding: 10px 12px;
  background: rgba(248, 248, 246, 0.6);
  border: 1px solid rgba(70, 70, 72, 0.4);
  border-radius: 4px;
}
.error { color: var(--accent-red); margin: 0; }

.primary {
  background: var(--ink);
  color: var(--kraft-light);
  border: 0;
  padding: 10px 18px;
  font-size: 18px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--hand-soft);
  letter-spacing: 0.04em;
}
.primary:hover { background: var(--ink-soft); }
.danger {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
  padding: 9px 16px;
  font-size: 18px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--hand-soft);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.editor-card { padding-bottom: 140px; }   /* 하단 플로팅 버튼바(2줄 접힘 대비)에 내용 안 가리게 */

/* ===== 에디터 뷰포트 미리보기 토글 (모바일/패드/데스크탑) ===== */
.viewport-toggle {
  display: inline-flex;
  gap: 0;
  margin: 0 auto 16px;
  border: 1px solid rgba(70, 70, 72, 0.35);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(248, 248, 246, 0.6);
}
.editor-card .viewport-toggle { display: flex; width: max-content; margin-left: auto; margin-right: auto; }
.viewport-btn {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  font-family: var(--hand-soft);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  letter-spacing: 0.04em;
}
.viewport-btn + .viewport-btn { border-left: 1px solid rgba(70, 70, 72, 0.2); }
.viewport-btn:hover { background: rgba(70, 70, 72, 0.06); }
.viewport-btn.is-active {
  background: var(--ink);
  color: var(--kraft-light);
}

/* 선택된 뷰포트 기준치(폭). 작은 디바이스에서 큰 모드를 선택하면 body 가 디바이스보다 넓어져서 가로 스크롤이 발생한다. */
body[data-viewport="mobile"]  { min-width: 0; }
body[data-viewport="mobile"]  .page { max-width: 420px;  }
body[data-viewport="tablet"]  { min-width: 820px; }
body[data-viewport="tablet"]  .page { max-width: 820px;  }
body[data-viewport="desktop"] { min-width: 1280px; }
body[data-viewport="desktop"] .page { max-width: 1280px; }
.editor-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.editor-head > .back         { justify-self: start; }
.editor-head > .hand         { justify-self: center; text-align: center; margin: 0; }
.editor-head > .status-badge { justify-self: end; }
.editor-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span,
.field > .label,
.field > legend {
  font-family: var(--hand-cute);
  color: var(--ink-soft);
  font-size: 16px;
}
.field input[type="text"],
.field input[type="date"],
.field input[type="password"],
.field select,
.field textarea {
  font-family: var(--hand);
  font-size: 18px;
  padding: 8px 10px;
  background: rgba(248, 248, 246, 0.55);
  border: 1px solid rgba(70, 70, 72, 0.4);
  border-radius: 4px;
  color: var(--ink);
  box-sizing: border-box;
  width: 100%;
}
/* 날짜 input: iOS 가 native 폭으로 줄여버리지 않게 appearance 제거(전폭 통일) + 달력 아이콘 노출(탭 가능 표시) */
.field input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
.field input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.5; }

/* 모달 공통 (admin 에디터 — letter 측 최초 도입) */
.qt-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.qt-modal-backdrop[hidden] { display: none; }

/* 토스트 — 에디터 Ctrl+S 저장 결과 등 화면 이동 없이 짧게 안내 */
.qt-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(40, 40, 42, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 1000;
}
.qt-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 에디터 하단 단축키 안내 */
.editor-shortcut-help {
  margin: 14px 0 0;
  padding: 10px 14px;
  background: rgba(248, 248, 246, 0.5);
  border-left: 3px solid var(--rule);
  border-radius: 4px;
  line-height: 1.55;
}
.editor-shortcut-help strong {
  color: var(--accent-red);
  font-weight: 700;
}

.qt-modal {
  position: relative;
  background: var(--kraft-light);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 22px;
  width: min(90vw, 420px);
  box-shadow: var(--shadow);
}
.qt-modal h2 { margin: 0 0 14px; font-family: var(--hand-soft); font-size: 22px; }
.qt-modal-close {
  position: absolute;
  top: 8px; right: 12px;
  background: transparent; border: 0;
  font-size: 28px; line-height: 1;
  color: var(--ink-soft);
  cursor: pointer; padding: 4px 8px;
}
.qt-modal-close:hover { color: var(--accent-red); }

/* 시각 선택 모달 — 0~23시 6x4 그리드 + 트리거 버튼 */
.time-input-wrap { display: inline-flex; align-items: center; gap: 6px; }
.time-picker-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(248, 248, 246, 0.55);
  border: 1px solid rgba(70, 70, 72, 0.4);
  border-radius: 4px;
  padding: 8px 14px;
  font-family: var(--hand);
  font-size: 18px;
  color: var(--ink);
  cursor: pointer;
  min-width: 130px;
}
.time-picker-btn:hover { background: rgba(40, 40, 42, 0.06); }
.time-picker-btn .time-icon { font-size: 18px; line-height: 1; }
.time-picker-btn .time-display { font-weight: 600; }

.time-modal { width: min(96vw, 420px); }
.time-modal h2 { text-align: center; }
.time-modal-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.hour-cell {
  background: #fff;
  border: 1px solid rgba(40,40,42,0.15);
  border-radius: 4px;
  padding: 12px 0;
  font-family: var(--hand);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
}
.hour-cell:hover { background: rgba(40,40,42,0.06); border-color: rgba(40,40,42,0.4); }
.hour-cell--current { border-color: var(--accent-red); color: var(--accent-red); font-weight: 700; }

/* 날짜 선택 모달 — 월 그리드 + 점유 날짜 disabled */
.date-modal { width: min(96vw, 420px); max-height: 90vh; overflow-y: auto; }
.date-modal h2 { text-align: center; }
.date-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 4px 0 10px;
}
.date-modal-month {
  font-family: var(--hand-soft); font-size: 20px; font-weight: 700; color: var(--ink);
}
.date-modal-nav {
  background: transparent; border: 1px solid rgba(40,40,42,0.25);
  border-radius: 4px; padding: 4px 14px; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--ink);
}
.date-modal-nav:hover { background: rgba(40,40,42,0.06); }
.date-modal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  text-align: center; font-family: var(--hand-cute); color: var(--ink-soft); font-size: 14px;
  margin-bottom: 4px;
}
.date-modal-weekdays .dow-sun { color: var(--accent-red); }
.date-modal-weekdays .dow-sat { color: #1f5fab; }
.date-modal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.date-cell {
  background: #fff; border: 1px solid rgba(40,40,42,0.15);
  border-radius: 4px; padding: 10px 0; font-family: var(--hand);
  font-size: 16px; color: var(--ink); cursor: pointer; line-height: 1;
}
.date-cell--blank { background: transparent; border-color: transparent; cursor: default; }
.date-cell:hover:not([disabled]) { background: rgba(40,40,42,0.06); border-color: rgba(40,40,42,0.4); }
.date-cell--occupied {
  background: rgba(40,40,42,0.08); color: rgba(40,40,42,0.35);
  cursor: not-allowed; text-decoration: line-through;
}
.date-cell--current {
  border-color: var(--accent-red); color: var(--accent-red); font-weight: 700;
}
.date-modal-hint { margin: 10px 0 0; text-align: center; }

/* 날짜 input — 우측 안쪽 명시적 달력 버튼 (브라우저 native indicator 가 잘 안 떠서 시인성 보강) */
.date-input-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.field .date-input-wrap input[type="date"] {
  padding-right: 44px;
  width: 100%;
}
.date-input-wrap input[type="date"]::-webkit-calendar-picker-indicator {
  display: none;
  opacity: 0;
  -webkit-appearance: none;
  appearance: none;
}
.date-input-wrap input[type="date"]::-webkit-inner-spin-button,
.date-input-wrap input[type="date"]::-webkit-clear-button { display: none; }
.date-input-wrap input[type="date"] { -webkit-appearance: none; appearance: none; }
.date-picker-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 22px;
  padding: 4px 8px;
  line-height: 1;
  color: var(--ink-soft);
  z-index: 1;
}
.date-picker-btn:hover { color: var(--accent-red); }
/* 셀렉트 — 네이티브 화살표 끄고 텍스트 가까이 위치한 커스텀 화살표 */
.field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a3f30' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 10px;
}
/* 3-컬럼 변형 — 날짜 / 요일 / 공개시각 한 줄. 어떤 폭에서도 한 줄 유지 + 높이/정렬 통일.
   라벨·input 폰트는 글로벌 .field 룰(라벨 16, value 18) 그대로 따르고, 모바일도 동일. */
.field-row--three {
  grid-template-columns: minmax(130px, 5fr) minmax(38px, 2fr) minmax(80px, 3fr);
  gap: 6px;
  align-items: end;
}
/* input/button 높이·정렬 통일 — 폰트는 글로벌 룰(value 18) 그대로 사용 */
.field-row--three input[type="date"],
.field-row--three input[type="text"],
.field-row--three .time-picker-btn {
  height: 40px;
  padding: 6px 8px;
  text-align: center;
  box-sizing: border-box;
}
.field-row--three .time-picker-btn {
  min-width: 0;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 18px;
}
.field-row--three .time-icon { font-size: 16px; }
.field-row--three .time-display { font-size: 18px; font-weight: 600; }
.field-row--three .date-input-wrap input[type="date"] { padding-right: 32px; }
.field-row--three .date-picker-btn { right: 4px; padding: 4px 4px; font-size: 18px; }

/* 모바일 — 기본 2컬럼만 1열로 펼침. --three 는 그리드 명시로 한 줄 유지(폰트 약간만 축소). */
@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr; gap: 12px; }
  .field-row--three {
    grid-template-columns: minmax(120px, 5fr) minmax(34px, 2fr) minmax(70px, 3fr);
    gap: 4px;
  }
  .field-row--three input[type="date"],
  .field-row--three input[type="text"],
  .field-row--three .time-picker-btn {
    height: 36px;
    padding: 4px 4px;
    font-size: 16px;
  }
  .field-row--three .time-picker-btn { font-size: 16px; gap: 2px; }
  .field-row--three .time-display { font-size: 16px; }
  .field-row--three .time-icon { font-size: 14px; }
  .field-row--three .date-input-wrap input[type="date"] { padding-right: 26px; }
  .field-row--three .date-picker-btn { right: 2px; padding: 4px 2px; font-size: 16px; }
}
/* viewport-toggle 미리보기 — body[data-viewport="mobile"] 도 동일 모바일 룰 강제 적용 */
body[data-viewport="mobile"] .field-row { grid-template-columns: 1fr; gap: 12px; }
body[data-viewport="mobile"] .field-row--three {
  grid-template-columns: minmax(120px, 5fr) minmax(34px, 2fr) minmax(70px, 3fr);
  gap: 4px;
}
body[data-viewport="mobile"] .field-row--three input[type="date"],
body[data-viewport="mobile"] .field-row--three input[type="text"],
body[data-viewport="mobile"] .field-row--three .time-picker-btn {
  height: 36px;
  padding: 4px 4px;
  font-size: 16px;
}
body[data-viewport="mobile"] .field-row--three .time-picker-btn { font-size: 16px; gap: 2px; }
body[data-viewport="mobile"] .field-row--three .time-display { font-size: 16px; }
body[data-viewport="mobile"] .field-row--three .time-icon { font-size: 14px; }
body[data-viewport="mobile"] .field-row--three .date-input-wrap input[type="date"] { padding-right: 26px; }
body[data-viewport="mobile"] .field-row--three .date-picker-btn { right: 2px; padding: 4px 2px; font-size: 16px; }
.bible {
  border: 1px dashed rgba(70, 70, 72, 0.4);
  padding: 12px;
  border-radius: 4px;
  margin: 0;                /* fieldset 기본 inline-margin 제거 */
  min-width: 0;             /* grid/flex 부모에서 오버플로우 방지 */
  box-sizing: border-box;
}
.bible-row {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 0.9fr;
  gap: 8px;
}

/* ===== 태그 입력 (칩 형태) ===== */
.tag-input-row {
  display: flex;
  gap: 8px;
}
.tag-input-row input[type="text"] {
  flex: 1;
  font-family: var(--hand);
  font-size: 18px;
  padding: 8px 10px;
  background: rgba(248, 248, 246, 0.55);
  border: 1px solid rgba(70, 70, 72, 0.4);
  border-radius: 4px;
  color: var(--ink);
  box-sizing: border-box;
}
.tag-input-row button {
  flex: 0 0 auto;
  padding: 8px 16px;
}
.tag-chips {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.tag-chips:empty { display: none; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  background: rgba(248, 248, 246, 0.7);
  border: 1px solid rgba(70, 70, 72, 0.35);
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink);
}
.tag-chip-remove {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-soft);
  padding: 0 2px;
}
.tag-chip-remove:hover { color: var(--accent-red); }
.verse-preview {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--ink-soft);
}
.verse-preview:empty { display: none; }

@font-face {
  font-family: 'omyu_pretty';
  src: url('/fonts/omyu_pretty.ttf') format('truetype');
  font-weight: normal; font-style: normal; font-display: swap;
}
.editor-area {
  background: rgba(248, 248, 246, 0.6);
  border: 1px solid rgba(70, 70, 72, 0.4);
  border-radius: 4px;
  min-height: 450px;
  max-width: 306px; margin-left: auto; margin-right: auto;
}
.prayer-textarea {
  font-family: var(--hand);
  font-size: 17px;
  line-height: 1.4;
  padding: 10px 12px;
  background: rgba(248, 248, 246, 0.55);
  border: 1px solid rgba(70, 70, 72, 0.4);
  border-radius: 4px;
  color: var(--ink);
  box-sizing: border-box;
  width: 100%;
  resize: vertical;
}

/* ===== SunEditor 톤 보정 — 사이트 크래프트 톤에 맞춤 ===== */
.sun-editor {
  border-color: rgba(70, 70, 72, 0.4) !important;
  border-radius: 4px !important;
  background: transparent;
  max-width: 306px;                    /* 에디터 위젯 좁게 고정 — 좁은 화면 넘침 방지 + 270px 편집영역과 정합 */
  margin-left: auto; margin-right: auto;
}
.sun-editor .se-toolbar {
  background: rgba(248, 248, 246, 0.85) !important;
  outline: none;
  border-bottom: 1px solid rgba(70, 70, 72, 0.3) !important;
}
.sun-editor .se-wrapper,
.sun-editor .se-wrapper-inner {
  background: rgba(248, 248, 246, 0.6) !important;
}
.sun-editor .se-wrapper .se-wrapper-inner {
  font-family: var(--hand);
  color: var(--ink);
  line-height: 1.3 !important;
}
.sun-editor .se-wrapper .sun-editor-editable,
.sun-editor .se-wrapper .se-wrapper-wysiwyg.sun-editor-editable {
  line-height: 1.3 !important;
  /* iOS 는 편집영역 폰트<16px 이면 포커스 시 화면을 확대함 → 16px 로 고정해 방지 */
  font-size: 20px !important;      /* 20≥16 → iOS 포커스 확대 없음 + 이미지 기본(20→60)과 동일 스케일 */
  line-height: 1.6 !important;     /* 이미지 줄간격(size×1.6)과 맞춤 */
  font-family: 'omyu_pretty', 'Nanum Myeongjo', serif !important;
  width: 270px !important; margin: 0 auto !important;   /* 폭 완전 고정(기기 무관) — 이미지 텍스트폭 810px÷3 = 270, 개행 일치 */
  box-sizing: border-box; padding-left: 0 !important; padding-right: 0 !important;
  word-break: break-all;   /* 이미지처럼 글자단위 줄바꿈 */
}
.sun-editor .se-wrapper .sun-editor-editable p { padding-bottom: 0; }
/* 화면이 편집영역(300px)보다 좁으면(폴드 커버 등) 줄이지 말고 가로 스크롤 */
.sun-editor .se-wrapper { overflow-x: auto; }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.actions-spacer { flex: 1; }
.autosave-row { display: flex; justify-content: flex-end; margin-top: 6px; min-height: 1.2em; }
.autosave-status { color: var(--ink-soft); font-size: 14px; }

/* htmx 진행 표시 */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ===== 플로팅 버튼 (FAB) =====
   - 하단 중앙: 좌(이전) / 위(최상단) / 우(다음) — 서신 이동
   - 하단 우측: 메뉴 트리거(☰) + 좌측 뒤로(‹) + 우리서신/목록/캘린더 펼침
   - 두 그룹 모두 `bottom: 18px` 같은 선상에 위치 */
/* 중앙 그룹 — 좌·↑·우 컴팩트(간격 4px) */
.fab-nav-group {
  position: fixed;
  bottom: 18px;
  left: 50%;
  margin-left: -76px;          /* 폭 152 의 절반 */
  width: 152px;                /* 48 + 4 + 48 + 4 + 48 */
  height: 48px;
  z-index: 50;
  pointer-events: none;
  transition: opacity 240ms ease, transform 280ms cubic-bezier(.2,.7,.3,1.4);
}
.fab-nav-group > * { pointer-events: auto; }

/* 좌측 하단 — 뒤로가기 단독 그룹 */
.fab-back-group {
  position: fixed;
  bottom: 18px;
  left: 18px;
  width: 48px;
  height: 48px;
  z-index: 50;
  transition: opacity 240ms ease, transform 280ms cubic-bezier(.2,.7,.3,1.4);
}
.fab-back-btn { position: relative; }   /* ::after 툴팁 자기 기준 */

/* 우측 하단 — 메뉴 트리거 단독, 펼치면 위로 3개 */
.fab {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 48px;
  height: 48px;
  z-index: 50;
  transition: opacity 240ms ease, transform 280ms cubic-bezier(.2,.7,.3,1.4),
              height 200ms ease;
  pointer-events: none;
}
.fab > * { pointer-events: auto; }
.fab.is-open { height: 220px; }

.fab-trigger {
  position: absolute !important;
  bottom: 0;
  right: 0;
}

/* 트리거 햄버거 ↔ 닫기(X) 아이콘 토글 */
.fab-trigger .icon-close { display: none; }
.fab.is-open .fab-trigger .icon-menu  { display: none; }
.fab.is-open .fab-trigger .icon-close { display: inline; }

/* 화면에 한동안 반응이 없을 때 가장자리로 사라지는 효과 */
body.fab-hidden .fab-nav-group { opacity: 0; transform: translateY(80px);  pointer-events: none; }
body.fab-hidden .fab           { opacity: 0; transform: translateX(80px);  pointer-events: none; }
body.fab-hidden .fab-back-group { opacity: 0; transform: translateX(-80px); pointer-events: none; }

/* 페이지별 FAB 노출 제어 */
/* 캘린더 화면: ↑(상단이동) 자체가 무의미 → 숨김 */
body.page-calendar .fab-nav--up { display: none; }
/* 사용자 메인(home): 어디서 온 게 아니라 시작점 → 뒤로가기 무의미 → 숨김 */
body.page-home .fab-back-group { display: none; }

.fab-btn {
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 248, 246, 0.92);
  border: 1px solid rgba(70, 70, 72, 0.45);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  padding: 0;
  text-decoration: none;
  transition: background 150ms ease, transform 220ms cubic-bezier(.2,.7,.3,1.4),
              opacity 200ms ease, visibility 200ms;
}
.fab-btn:hover { background: rgba(248, 248, 246, 1); }
.fab-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

/* 하단 중앙 — 좌/위/우 (모두 같은 줄, bottom: 0). gap 4px 컴팩트 */
.fab-nav { position: absolute; }
.fab-nav--left  { bottom: 0; left: 0;     }
.fab-nav--up    { bottom: 0; left: 52px;  }   /* 48 + 4 */
.fab-nav--right { bottom: 0; left: 104px; }   /* 48 + 4 + 48 + 4 */

/* 이전/다음 서신 — 페이지 맨 아래로 스크롤한 시점에만 노출 */
.fab-nav--left, .fab-nav--right {
  visibility: hidden;
  opacity: 0;
  transition: opacity 200ms ease, visibility 200ms;
}
body.at-bottom .fab-nav--left,
body.at-bottom .fab-nav--right {
  visibility: visible;
  opacity: 1;
}

/* 하단 우측 — 트리거 + 펼침 메뉴 (메뉴는 .fab 컨테이너 기준) */
.fab-submenu {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 48px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.fab-submenu > li {
  position: absolute;
  bottom: 0;
  right: 0;
}
.fab-submenu .fab-btn {
  visibility: hidden;
  opacity: 0;
  transform: translate(0, 0);
  pointer-events: none;
}
.fab.is-open .fab-submenu .fab-btn { visibility: visible; opacity: 1; pointer-events: auto; }
/* 아이템 수가 페이지별로 다름(공유/다운로드 유무). 마지막 아이템부터 60px 간격으로 위로 쌓는다.
   nth-last-child(N) → translate(0, -(N-1)*60px). 최대 5개까지 지원 (-240px). */
.fab.is-open .fab-submenu li:nth-last-child(1) .fab-btn { transform: translate(0, 0); }
.fab.is-open .fab-submenu li:nth-last-child(2) .fab-btn { transform: translate(0, -60px); }
.fab.is-open .fab-submenu li:nth-last-child(3) .fab-btn { transform: translate(0, -120px); }
.fab.is-open .fab-submenu li:nth-last-child(4) .fab-btn { transform: translate(0, -180px); }
.fab.is-open .fab-submenu li:nth-last-child(5) .fab-btn { transform: translate(0, -240px); }

/* 캡처 중인 다운로드 버튼: 살짝 회전하는 다운 화살표로 진행 표시 */
.fab-btn.is-busy { opacity: 0.7; cursor: progress; }
.fab-btn.is-busy svg { animation: capture-spin 1.1s linear infinite; transform-origin: 50% 50%; }
@keyframes capture-spin {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}

/* ===== FAB 툴팁 =====
   data-tip 속성 텍스트를 버튼 왼쪽에 띄움. PC 는 hover/focus 시, 모바일은 .fab.is-open 시 (펼쳤을 때 라벨 항상 표시).
   ⚠️ position: relative 는 .fab-btn 자체에 주지 말 것 — .fab-nav--up/left/right 의 absolute 좌표를 깨뜨려 ↑/←/→ 가 한 줄에서 어긋남.
   모든 fab-btn 은 이미 absolute 또는 absolute 자식이라 ::after 가 자기 기준으로 잘 잡힘. */
.fab-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: 50%;
  right: calc(100% + 10px);
  transform: translateY(-50%);
  background: rgba(40, 28, 12, 0.92);
  color: #f6efd8;
  font-family: var(--hand-cute);
  font-size: 13px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease;
  z-index: 60;
}
/* 좌측 끝(이전) 버튼은 왼쪽이 화면 밖이라 오른쪽으로 띄움 */
.fab-nav--left[data-tip]::after {
  right: auto;
  left: calc(100% + 10px);
}
/* 우측 끝 트리거 — 위쪽으로 옮겨 펼친 메뉴 가리지 않도록 */
.fab-trigger[data-tip]::after {
  top: auto;
  bottom: calc(100% + 10px);
  right: 50%;
  transform: translateX(50%);
}
/* 펼친 메뉴 안 버튼만 좁게 relative 부여 — transform 따라 ::after 도 함께 이동. */
.fab-submenu .fab-btn[data-tip] { position: relative; }
/* 펼친 상태 — 모바일/PC 모두 라벨 노출 (사용자가 어떤 버튼인지 알 수 있게). */
.fab.is-open .fab-btn[data-tip]::after { opacity: 1; }

@media (hover: hover) and (pointer: fine) {
  /* PC 호버/포커스 — 펼치지 않은 상태에서도 라벨 노출 */
  .fab-btn[data-tip]:hover::after,
  .fab-btn[data-tip]:focus-visible::after { opacity: 1; }
}

/* ===== 상태 뱃지 (관리자 전용) — 손글씨 밑줄로 표시 ===== */
.status-badge {
  display: inline-block;
  padding: 2px 4px 6px;
  font-size: 13px;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 0.02em;
  line-height: 1.1;
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 6px;
}
/* 임시저장: 손글씨 점선 밑줄 (회색) */
.status-draft {
  color: var(--ink-soft);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 8 2, 14 4 T 26 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M32 4 Q 38 2, 44 4 T 56 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M62 4 Q 68 2, 74 4 T 86 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/><path d='M92 4 Q 98 2, 104 4 T 116 4' stroke='%23464648' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='0.75'/></svg>");
}
/* 발행됨: 손글씨 실선 밑줄 (빨강) */
.status-published {
  color: var(--accent-red);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 20 1, 40 4 T 80 4 T 118 4' stroke='%23b13b34' stroke-width='1.6' fill='none' stroke-linecap='round'/><path d='M3 4.6 Q 22 2, 42 4.4 T 82 4.4 T 117 4.2' stroke='%23b13b34' stroke-width='1' fill='none' stroke-linecap='round' opacity='0.5'/></svg>");
}

/* ===== 캘린더 범례 (관리자) — 뱃지와 동일한 밑줄 톤 ===== */
.cal-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  font-size: 14px;
  color: var(--ink-soft);
}
.legend-dot {
  display: inline-block;
  width: 22px;
  height: 6px;
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 6px;
}
.legend-published {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 20 1, 40 4 T 80 4 T 118 4' stroke='%23b13b34' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
}
.legend-draft {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'><path d='M2 4 Q 8 2, 14 4 T 26 4' stroke='%23b13b34' stroke-width='1.4' fill='none' stroke-linecap='round'/><path d='M32 4 Q 38 2, 44 4 T 56 4' stroke='%23b13b34' stroke-width='1.4' fill='none' stroke-linecap='round'/><path d='M62 4 Q 68 2, 74 4 T 86 4' stroke='%23b13b34' stroke-width='1.4' fill='none' stroke-linecap='round'/><path d='M92 4 Q 98 2, 104 4 T 116 4' stroke='%23b13b34' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
}

/* ===== secondary 버튼 (임시저장 등) ===== */
.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(70, 70, 72, 0.5);
  padding: 9px 16px;
  font-size: 18px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--hand-soft);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.secondary:hover { background: rgba(248, 248, 246, 0.6); border-bottom: 1px solid rgba(70, 70, 72, 0.5); }

/* ===== 에러 페이지 ===== */
.error-card {
  text-align: center;
  padding: 64px 24px;
}
.error-reason {
  font-family: var(--hand-soft);
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 28px;
}
.error-actions {
  display: flex;
  justify-content: center;
}
.error-actions .primary {
  display: inline-block;
  text-decoration: none;
}

/* ==========================================================
 * 공감 바 — 카운트 pill + 작은 + 버튼 (picker 펼침)
 * 기기단위(쿠키 device_id), 로그인 없이 작동.
 * ========================================================== */
.reaction-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
  padding-top: 12px;
  position: relative;
}
.reaction-counts {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.reaction-counts:empty { display: none; }

.reaction-pill,
.reaction-add,
.reaction-pick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--paper-tint);
  border: 1px solid rgba(40, 40, 42, 0.2);
  border-radius: 999px;
  font-size: 16px;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.reaction-pill:hover,
.reaction-add:hover,
.reaction-pick:hover {
  background: var(--paper-tint-2);
  border-color: rgba(40, 40, 42, 0.45);
}
.reaction-pill:active,
.reaction-add:active,
.reaction-pick:active { transform: scale(0.94); }
.reaction-pill[disabled],
.reaction-pick[disabled] { opacity: 0.5; cursor: wait; }
.reaction-pill.is-mine,
.reaction-pick.is-mine {
  background: rgba(177, 59, 52, 0.12);
  border-color: var(--accent-red);
  color: var(--ink);
}

.reaction-add {
  padding: 3px 8px;
  color: var(--ink-soft);
  opacity: 0.85;
}
.reaction-add:hover { opacity: 1; }

.reaction-picker {
  display: inline-flex;
  gap: 4px;
  padding: 4px 6px;
  background: var(--paper-tint-2);
  border: 1px solid rgba(40, 40, 42, 0.25);
  border-radius: 999px;
  animation: reaction-picker-in 140ms ease-out;
}
.reaction-picker[hidden] { display: none; }
.reaction-picker .reaction-pick {
  padding: 6px 12px;
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
}
.reaction-picker .reaction-pick:hover { background: rgba(70, 70, 72, 0.06); transform: scale(1.15); }
.reaction-picker .reaction-pick.is-mine { background: rgba(177, 59, 52, 0.16); border: 0; }

@keyframes reaction-picker-in {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════════════════════════════════════════
   테마 — FAB '배경 테마' 에서 선택, localStorage('hwoori:bgTheme').
   라이트/다크(배경+글자색) · 편지지 2종(서신/큐티 종이) · 내 색상(배경+폰트).
   각 테마가 --theme-bg / --theme-bg-image / --ink 설정 → body::before·미리보기 공용. */
html[data-theme="light"] { --theme-bg: #ffffff; --theme-bg-image: none; --ink: #1a1a1a; background-color: #ffffff; }
html[data-theme="dark"]  {
  --theme-bg: #1c1c1e; --theme-bg-image: none; background-color: #1c1c1e;
  --ink: #f2f2f2; --ink-soft: #bcbcc0; --rule: #5a5a5e;
  --paper-tint: rgba(255,255,255,0.06); --paper-tint-2: rgba(255,255,255,0.10); --paper-tint-3: rgba(255,255,255,0.14);
  --accent-red: #e0685f;   /* 다크 배경에서 더 밝은 붉은색 */
}
html[data-theme="letter-image"] { --theme-bg: #e5e6e3; --theme-bg-image: url('/images/paper-bg.jpg'); background-color: #e5e6e3; }
html[data-theme="qt-image"]     { --theme-bg: #d9c0a0; --theme-bg-image: url('/images/paper-bg.jpg'); background-color: #d9c0a0; }
html[data-theme="custom"] {
  --theme-bg: var(--custom-bg, #e5e6e3); --theme-bg-image: none; background-color: var(--custom-bg, #e5e6e3);
  --ink: var(--custom-ink, #28282a);
}

/* 테마 선택 모달 */
.theme-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.42); }
.theme-modal[hidden] { display: none; }
.theme-modal-card { background: #f4f2ee; border: 1px solid rgba(40,40,42,0.15); border-radius: 14px; padding: 20px; width: min(92vw, 360px); max-height: 88vh; overflow-y: auto; box-shadow: 0 12px 44px rgba(0,0,0,0.28); }
html[data-theme="dark"] .theme-modal-card { background: #2a2a2e; border-color: rgba(255,255,255,0.16); }
.theme-modal-title { font-family: var(--hand-soft); font-size: 20px; font-weight: 700; color: var(--ink); margin: 0 0 14px; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.theme-opt { display: flex; flex-direction: column; align-items: stretch; gap: 8px; cursor: pointer; border: 2px solid transparent; border-radius: 10px; padding: 8px; background: none; }
.theme-opt.is-active { border-color: var(--accent-red, #b13b34); }
.theme-swatch { height: 52px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.18); background-repeat: repeat; background-size: 600px auto; background-blend-mode: luminosity; }
.theme-swatch--light { background-color: #ffffff; }
.theme-swatch--dark  { background-color: #1c1c1e; }
.theme-swatch--letter-image { background-color: #e5e6e3; background-image: url('/images/paper-bg.jpg'); }
.theme-swatch--qt-image     { background-color: #d9c0a0; background-image: url('/images/paper-bg.jpg'); }
.theme-opt-label { font-size: 14px; font-weight: 600; color: var(--ink); text-align: center; }
/* 내 색상: 배경색 / 폰트색 */
.theme-custom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.theme-custom-field { display: flex; flex-direction: column; align-items: stretch; gap: 8px; cursor: pointer; border: 2px solid transparent; border-radius: 10px; padding: 8px; position: relative; }
.theme-custom-field.is-active { border-color: var(--accent-red, #b13b34); }
.theme-swatch--custombg  { background-color: var(--custom-bg, #e5e6e3); }
.theme-swatch--customink { background-color: var(--custom-ink, #28282a); }
.theme-color-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
/* 미리보기 */
.theme-preview { margin-top: 12px; padding: 20px 12px; border-radius: 8px; border: 1px solid var(--rule, #7c7c7e); background-color: var(--theme-bg, #e5e6e3); background-image: var(--theme-bg-image, none); background-size: 600px auto; background-repeat: repeat; background-blend-mode: luminosity; color: var(--ink); text-align: center; font-size: 18px; font-weight: 600; }
.theme-modal-close { margin-top: 12px; width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--rule, #7c7c7e); background: none; color: var(--ink); font-weight: 600; cursor: pointer; }

/* ── 다크 모드 — 밝은 배경 전제 chrome 보정 (FAB 흰버튼·인풋) ── */
html[data-theme="dark"] .fab-btn:not(.fab-btn--accent) { background: rgba(48,48,52,0.96); border-color: rgba(255,255,255,0.22); }
html[data-theme="dark"] .fab-btn:not(.fab-btn--accent):hover { background: rgba(66,66,70,1); }
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .combo-input,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] textarea { background: #2a2a2e; color: var(--ink); border-color: rgba(255,255,255,0.22); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: rgba(255,255,255,0.42); }
/* primary 버튼: 다크에선 배경 --ink(밝음) 이므로 글씨를 어둡게 */
html[data-theme="dark"] .primary,
html[data-theme="dark"] .primary:hover { color: #1a1a1a; }

/* ── 배경 라이브러리(/bg) ─────────────────────────────────────── */
.bg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bg-count { font-size: 14px; color: var(--muted, #7c7c7e); }
.bg-admin-btn { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--rule, #7c7c7e); background: none; color: var(--ink); font-weight: 600; cursor: pointer; }
.bg-desc { margin: 4px 0 16px; font-size: 14px; color: var(--muted, #7c7c7e); line-height: 1.5; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
@media (min-width: 640px) { .bg-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; } }
.bg-tile { position: relative; margin: 0; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: rgba(0,0,0,0.06); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.18); }
.bg-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-tile figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 11px; line-height: 1.3; color: #fff; text-align: center; background: linear-gradient(to top, rgba(0,0,0,0.62), rgba(0,0,0,0)); text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.bg-del { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border: none; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; font-size: 17px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.bg-del:hover { background: rgba(200,40,40,0.9); }
/* 추가 타일 */
.bg-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--rule, #9a9a9c); background: rgba(0,0,0,0.03); color: var(--muted, #7c7c7e); cursor: pointer; box-shadow: none; }
.bg-add:hover { border-color: var(--ink); color: var(--ink); }
.bg-add-plus { font-size: 34px; line-height: 1; font-weight: 300; }
.bg-add-label { font-size: 12px; font-weight: 600; }
.bg-add.is-loading { opacity: 0.5; pointer-events: none; }
.bg-add.is-loading .bg-add-plus { animation: bg-spin 0.9s linear infinite; }
@keyframes bg-spin { to { transform: rotate(360deg); } }
/* 라이트박스(전체화면) */
.bg-lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; background: #000; }
.bg-lightbox[hidden] { display: none; }
.bg-lightbox img { max-width: 100%; max-height: 82vh; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.bg-lightbox-cap { color: #fff; font-size: 15px; text-align: center; }
.bg-lightbox-close { position: absolute; top: 16px; right: 18px; width: 42px; height: 42px; border: none; border-radius: 50%; background: rgba(255,255,255,0.14); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.bg-lightbox-close:hover { background: rgba(255,255,255,0.28); }

/* ── 상세: 다운로드 미리보기 + 배경 셔플 ─────────────────────── */
.note-preview { margin: 4px 0 22px; text-align: center; }
.note-preview-img { width: 100%; max-width: 320px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.20); background: rgba(0,0,0,0.05); }
.note-preview-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* ── 좁은 화면(폴드 접힘 등) — 버튼 줄바꿈 최소화 + 축소 ─────── */
@media (max-width: 400px) {
  .pv-btn { padding: 8px 11px; font-size: 13px; gap: 5px; }
  .pv-btn svg { width: 15px; height: 15px; }
  .detail-fab-btn:not(.detail-fab-btn--label) { width: 42px; height: 42px; }
  .detail-fab-btn svg { width: 21px; height: 21px; }
  .detail-fab-btn.center svg { width: 23px; height: 23px; }
  .detail-fab-btn--label { padding: 0 10px; height: 38px; gap: 4px; }
  .detail-fab-btn--label span { font-size: 13px; }
  .detail-fab-btn--label svg { width: 16px; height: 16px; }
  .form-fab { gap: 4px; padding: 6px; }
}
.pv-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; border: 1px solid rgba(70,70,72,0.25); background: var(--kraft-light, #f0f1ee); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.pv-btn svg { width: 17px; height: 17px; }
.pv-btn:active { transform: translateY(1px); }
.pv-btn--save { background: var(--ink); color: #f4f1ea; border-color: var(--ink); }
html[data-theme="dark"] .pv-btn:not(.pv-btn--save) { background: rgba(48,48,52,0.96); border-color: rgba(255,255,255,0.22); }
.pv-btn--ghost { background: transparent; color: var(--ink-soft, #4a4a4c); border-color: rgba(70,70,72,0.2); }
html[data-theme="dark"] .pv-btn--ghost { background: transparent; border-color: rgba(255,255,255,0.2); }

/* ── 메인 카드목록(공유 이미지 갤러리) ─────────────────────── */
.shot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .shot-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
.shot { position: relative; margin: 0; }
.shot-img {
  display: block; width: 100%; padding: 0; border: none; margin: 0;
  aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; cursor: zoom-in;
  background: rgba(0,0,0,0.06); box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.shot-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-dl { position: absolute; top: 8px; right: 8px; z-index: 3; width: 34px; height: 34px; }
.shot-dl svg { width: 16px; height: 16px; }
.shot-cap { display: block; margin-top: 6px; line-height: 1.25; }
.shot-cap:hover { text-decoration: none; }
.shot-date { display: block; font-size: 12px; color: var(--ink-soft); }
.shot-title { display: block; font-size: 14px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 라이트박스(확대 + 저장) — 배경 라이트박스와 동일 톤 */
.shot-lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; background: #000; }
.shot-lightbox[hidden] { display: none; }
.shot-lightbox img { max-width: 100%; max-height: 78vh; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.shot-lb-actions { display: flex; gap: 10px; }
.shot-lb-close { position: absolute; top: 16px; right: 18px; width: 42px; height: 42px; border: none; border-radius: 50%; background: rgba(255,255,255,0.14); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.shot-lb-close:hover { background: rgba(255,255,255,0.28); }
