:root {
  color-scheme: light;
  --paper: #f6f1e7;
  --card: #fffdf8;
  --ink: #2b2620;
  --ink-soft: #6f6558;
  --line: #cfc4b0;
  --line-soft: #e6dece;
  --seal: #a8402f;
  --seal-soft: #f3e1da;
  --serif: 'Noto Serif KR', 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --card-w: 84px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
p { margin: 0; }
.hint { color: var(--ink-soft); font-size: 14px; }
.error { color: var(--seal); font-size: 14px; min-height: 1.5em; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--ink-soft); }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--card); }
button.danger { color: var(--seal); }
button.primary.danger-fill { background: var(--seal); border-color: var(--seal); }
.ask-message { font-size: 17px; line-height: 1.6; word-break: keep-all; }
.ask-gender { display: flex; gap: 8px; margin-top: 12px; }
.ask-gender label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 17px; cursor: pointer; }
.ask-gender label:has(input:checked) { border-color: var(--seal); background: var(--seal-soft); }
.ask-gender input { width: 18px; height: 18px; margin: 0; accent-color: var(--seal); }
.ask-gender[hidden] { display: none; }
button.link { border: 0; background: none; padding: 0; color: var(--ink-soft); text-decoration: underline; font-size: 14px; }
input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}
:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }

.seal {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  background: var(--seal);
  color: #fff;
  font-family: var(--serif);
  font-size: 30px;
  border-radius: 10px;
}
.seal.small { width: 30px; height: 30px; font-size: 17px; border-radius: 6px; flex: none; }

/* ---------- 로그인 ---------- */

#login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 32px 28px;
  display: grid;
  gap: 14px;
  text-align: center;
}
.login-card .seal { margin: 0 auto; }
.login-card h1 { font-size: 24px; word-break: keep-all; text-wrap: balance; }
.login-card label { text-align: left; font-size: 14px; color: var(--ink-soft); display: grid; gap: 4px; }
.login-card input { font-size: 18px; }
.login-card button { padding: 12px; font-size: 17px; }
.login-card .install { font-size: 15px; color: var(--ink-soft); }
.login-options { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 22px; }
.login-card label.check { display: flex; align-items: center; gap: 7px; font-size: 16px; color: var(--ink); white-space: nowrap; cursor: pointer; }
.login-card label.check input { width: 19px; height: 19px; accent-color: var(--ink); }
.login-card input::placeholder { font-size: 15px; }

/* 바탕화면 바로가기 만드는 순서 안내. 어른들이 읽기 편하게 글씨를 크게 */
.install-help { width: min(440px, calc(100vw - 32px)); }
.install-help section { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.install-help h3 { font-size: 17px; }
.install-help ol { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; font-size: 16px; line-height: 1.6; word-break: keep-all; }
.install-help b { font-weight: 600; }

/* ---------- 상단 ---------- */

#app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--card);
  flex-wrap: wrap;
}
/* 도장과 제목 글자를 세로 가운데로 맞춘다 */
.topbar h1 { display: flex; align-items: center; gap: 10px; font-size: 19px; line-height: 1.2; margin-right: auto; white-space: nowrap; }
.site-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.views { display: flex; gap: 12px; }
.segmented, .zoom { display: flex; }
.segmented button, .zoom button { border-radius: 0; margin-left: -1px; padding: 6px 12px; font-size: 14px; }
.segmented button:first-child, .zoom button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.segmented button:last-child, .zoom button:last-child { border-radius: 0 8px 8px 0; }
.segmented button.active { background: var(--ink); border-color: var(--ink); color: var(--card); }

.menu { position: relative; }
.menu summary { cursor: pointer; padding: 6px 4px; font-size: 14px; white-space: nowrap; }
.menu-items {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 170px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 4px;
}
.menu-items p { font-size: 13px; color: var(--ink-soft); padding: 4px 8px; }
.menu-items button { border: 0; text-align: left; background: none; }
.menu-items button:hover { background: var(--paper); }

/* ---------- 본문 ---------- */

.stage { flex: 1; min-height: 0; display: flex; }
.viewport { flex: 1; min-width: 0; overflow: auto; }
.viewport.tree { cursor: grab; user-select: none; }
.viewport.dragging { cursor: grabbing; }

/* ---------- 인물 카드 ---------- */

.card {
  width: var(--card-w);
  padding: 0;
  border: 0;
  background: none;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  justify-items: center;
}
.portrait {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  position: relative;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait .initial { font-family: var(--serif); font-size: 22px; color: var(--ink-soft); }
.card .name { font-family: var(--serif); font-size: 15px; white-space: nowrap; }
.card:hover .portrait { border-color: var(--ink-soft); }
.card.selected .portrait { border-color: var(--seal); box-shadow: 0 0 0 2px var(--seal); }
.card.editable .portrait::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--seal);
  border: 1.5px solid var(--card);
}
.dragover .portrait, .portrait.dragover, .album-add.dragover { border: 2px dashed var(--seal); background: var(--seal-soft); }

.unit { display: flex; gap: 6px; }

/* ---------- 가계도 ---------- */

.tree { width: max-content; margin: 0 auto; padding: 24px; }
.tree ul { display: flex; justify-content: center; margin: 0; padding: 22px 0 0; position: relative; }
.tree > ul { padding-top: 0; }
.tree li { list-style: none; position: relative; padding: 22px 7px 0; display: flex; flex-direction: column; align-items: center; }
.tree > ul > li { padding-top: 0; }

/* 형제를 잇는 가로선과 각자에게 내려오는 세로선 */
.tree li::before, .tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: 22px;
  border-top: 1px solid var(--line);
}
.tree li::after { right: auto; left: 50%; border-left: 1px solid var(--line); }
.tree li:first-child::before, .tree li:last-child::after { border-top: 0; }
.tree li:last-child::before { border-right: 1px solid var(--line); border-radius: 0 6px 0 0; }
.tree li:last-child::after { border-left: 0; }
.tree li:first-child::after { border-radius: 6px 0 0 0; }
.tree li:only-child::before { border-radius: 0; }
.tree > ul > li::before, .tree > ul > li::after { display: none; }
/* 부모에서 내려오는 세로선 */
.tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  height: 22px;
  border-left: 1px solid var(--line);
}

/* 막내 세대는 세로로 쌓고 왼쪽 선에서 가지를 낸다 */
.tree ul.stack { flex-direction: column; align-items: flex-start; }
.tree ul.stack::before { height: 11px; }
.tree ul.stack::after {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 50%;
  height: 11px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 6px 0 0 0;
}
.tree ul.stack > li { padding: 0 0 10px 16px; align-items: flex-start; }
.tree ul.stack > li::before {
  top: 0;
  left: 0;
  right: auto;
  width: 0;
  height: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}
.tree ul.stack > li:last-child::before { height: 56px; }
.tree ul.stack > li::after {
  top: 56px;
  left: 0;
  width: 12px;
  height: 0;
  border-left: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.unit-wrap { position: relative; padding-bottom: 6px; }
.toggle {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  z-index: 1;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-soft);
}

/* ---------- 목록 ---------- */

.list { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.family { background: var(--card); border: 1px solid var(--line-soft); border-radius: 14px; padding: 16px; }
.family.mine { border-color: var(--seal); }
.family h2 { font-size: 18px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.badge { font-family: var(--sans); font-size: 12px; font-weight: 400; background: var(--seal-soft); color: var(--seal); padding: 2px 8px; border-radius: 6px; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0 8px 14px;
  margin-left: calc(var(--depth) * 22px);
  border-left: 2px solid var(--line-soft);
}
.row .card { --card-w: 60px; }
.row .card .name { display: none; }
.row-text { display: grid; }
.row-text strong { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.row-text span { font-size: 13px; color: var(--ink-soft); }

/* ---------- 사진첩 ---------- */

.gallery { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.gallery-bar { display: flex; align-items: center; gap: 12px; }
/* 이름으로 사진 찾기. 왼쪽에 두고, 올리기 단추와 가족 고르기는 오른쪽으로 민다 */
.gallery-search { flex: 1 1 200px; max-width: 320px; margin-right: auto; padding: 9px 14px; font-size: 16px; }
.gallery-bar select { width: auto; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 12px; }
.gallery-grid figure { margin: 0; }
.gallery-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
  background: var(--line-soft);
}
/* 사진 아래: 찍은 날짜 한 줄, 나온 사람들 이름 (칸이 좁으면 줄을 바꾼다) */
.gallery-grid figcaption { display: grid; gap: 1px; margin-top: 5px; }
.gallery-date { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.gallery-names { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.gallery-names button { border: 0; background: none; padding: 0; font-family: var(--serif); font-size: 15px; white-space: nowrap; }
.gallery-names button:hover { text-decoration: underline; }
.gallery-names span { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.gallery-names .ask { font-family: var(--sans); font-size: 13px; color: var(--seal); text-decoration: underline; }
.gallery-bar .primary { font-size: 15px; padding: 8px 16px; white-space: nowrap; }
.gallery-uploads { display: flex; gap: 8px; }
.empty { text-align: center; padding: 56px 16px; display: grid; gap: 6px; }

/* ---------- 게시판 ---------- */

.board { max-width: 760px; margin: 0 auto; padding: 16px; }
/* 브라우저는 위쪽에 내용이 끼어들면 보던 자리를 지키려고 스크롤을 슬쩍 옮긴다.
   그러면 목록 위에 펼친 글로 올라가는 스크롤이 도중에 멈추므로 게시판에서는 끈다 */
.viewport.board { overflow-anchor: none; }

.board-write-row { position: relative; display: flex; justify-content: center; margin-bottom: 14px; }
.board-write { border-radius: 999px; font-size: 13px; padding: 5px 16px; }
.board-manage { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 13px; }

/* 분류 탭: 글자만 있고, 고른 탭 아래에 가는 밑줄. 양옆 44px은 돋보기 자리라서 탭이 정확히 가운데 온다 */
.board-tabs { position: relative; padding: 0 44px; margin: 18px 0 8px; min-height: 36px; }
.board-tab-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 18px; }
.board-tab {
  border: 0;
  border-bottom: 1.5px solid transparent;
  border-radius: 0;
  background: none;
  padding: 6px 2px;
  font-size: 15px;
  color: var(--ink-soft);
}
.board-tab:hover { color: var(--ink); }
.board-tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* 검색칸은 탭 줄 위에 떠서 왼쪽으로 펼쳐진다. 탭이 밀리거나 줄이 바뀌지 않는다 */
.board-search-btn {
  position: absolute;
  right: 0;
  top: 1px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.board-search {
  position: absolute;
  right: 0;
  top: 1px;
  z-index: 1;
  width: 34px;
  overflow: hidden; /* 접혀 있을 때 입력칸이 삐져나와 화면이 옆으로 밀리지 않게 */
  opacity: 0;
  pointer-events: none;
  transition: width 0.18s ease, opacity 0.18s ease;
}
.board-tabs.search-open .board-search { width: min(340px, 100%); overflow: visible; opacity: 1; pointer-events: auto; }
.board-search input { height: 34px; border-radius: 17px; padding: 0 70px 0 14px; font-size: 14px; }
.board-search input::-webkit-search-cancel-button { display: none; }
.board-search-close { position: absolute; right: 38px; top: 3px; width: 28px; height: 28px; padding: 0; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--ink-soft); }
.board-tabs.search-open .board-search-btn { border-color: transparent; background: none; }

/* 글 목록: 넓은 화면에서는 표처럼 한 줄 */
.board-list { list-style: none; margin: 0; padding: 0; }
.board-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 130px 64px;
  align-items: center;
  gap: 0 8px;
  width: 100%;
  padding: 11px 8px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: none;
  font-size: 15px;
  text-align: left;
}
.board-head { padding: 8px; border-bottom: 1.5px solid var(--ink); font-size: 13px; color: var(--ink-soft); text-align: center; }
button.board-row:hover { background: #faf6ee; }
.board-row.notice { background: #eee8db; }
.board-row.current { background: var(--seal-soft); }
.board-no, .board-author, .board-date { text-align: center; font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.board-author { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-date.today { color: var(--seal); }
/* 한글은 낱말 중간에서 끊지 않되, 긴 주소처럼 끊을 곳이 없는 글자는 칸 안에서 줄을 바꾼다 */
.board-title { overflow-wrap: anywhere; word-break: keep-all; }
.board-sep { margin: 0 7px; color: var(--line); }
.board-current { display: none; margin-left: 8px; font-style: normal; font-size: 13px; color: var(--seal); }
.board-row.current .board-current { display: inline; }

.board-pager { display: flex; justify-content: center; gap: 4px; margin: 18px 0 32px; }
.board-pager button { min-width: 34px; padding: 5px 8px; font-size: 14px; border-color: transparent; background: none; }
.board-pager button.active { background: var(--ink); color: var(--card); }
.board-pager button:disabled { color: var(--line); cursor: default; }

/* 펼친 글, 글쓰기 창 */
.board-post, .board-form { background: var(--card); border: 1px solid var(--line-soft); border-radius: 14px; padding: 20px; margin-bottom: 10px; }
.board-detail { scroll-margin-top: 12px; }
.board-post h2 { font-size: 20px; overflow-wrap: anywhere; word-break: keep-all; }
.board-post .meta { margin: 6px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; color: var(--ink-soft); }
.board-post .actions { margin-top: 20px; }
.board-form { display: grid; gap: 12px; }
.board-form-head { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; }

.board-body { line-height: 1.75; overflow-wrap: anywhere; word-break: keep-all; }
.board-body p { margin: 0 0 0.6em; }
.board-body ul, .board-body ol { margin: 0 0 0.6em; padding-left: 1.6em; }
.board-body a { color: var(--seal); }
.board-body img { display: block; max-width: 100%; height: auto; margin: 8px 0; border-radius: 6px; cursor: zoom-in; }
.yt-embed { position: relative; aspect-ratio: 16 / 9; max-width: 100%; margin: 10px 0; border-radius: 8px; overflow: hidden; background: #1c1814; }
.yt-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.board-comment-count { margin-left: 6px; font-size: 13px; color: var(--seal); font-variant-numeric: tabular-nums; }

/* 댓글. 대댓글은 한 단계 들여 쓴다 */
.comments { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line-soft); display: grid; gap: 12px; }
.comments h3 { font-size: 17px; }
.comments h3 span { color: var(--seal); font-family: var(--sans); font-size: 15px; }
.comment-list, .comment-thread ul { list-style: none; margin: 0; padding: 0; }
.comment-thread { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.comment-thread:first-child { padding-top: 0; }
.comment.reply { margin: 10px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line-soft); }
.comment-head { display: flex; align-items: baseline; gap: 8px; }
.comment-head strong { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.comment-head span { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.comment-body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: keep-all; line-height: 1.6; }
.comment-body a { color: var(--seal); }
.comment-deleted { color: var(--ink-soft); font-size: 14px; }
.comment-actions { display: flex; gap: 12px; margin-top: 2px; }
.comment-actions .link { font-size: 13px; text-decoration: none; }
.comment-actions .link:hover { text-decoration: underline; }
.comment-form { display: grid; gap: 6px; }
.comment-form.reply { margin: 10px 0 0 18px; }
.comment-form textarea { resize: vertical; font-size: 16px; line-height: 1.5; }
.comment-form .error { min-height: 0; }
.comment-form .error:empty { display: none; }
.comment-form .actions button { padding: 7px 16px; font-size: 15px; }
.board-post .comment-form .actions { margin-top: 0; }

/* 본문 편집기 */
.editor { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.editor-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line-soft); }
.editor-tool { min-width: 32px; height: 32px; padding: 0 8px; border-color: transparent; background: none; font-size: 14px; display: inline-grid; place-items: center; }
.editor-tool:hover { background: var(--paper); border-color: transparent; }
.editor-tool.bold { font-weight: 700; }
.editor-tool.italic { font-style: italic; }
.editor-tool.underline { text-decoration: underline; }
.editor-tool.strike { text-decoration: line-through; }
.editor-gap { width: 1px; height: 18px; margin: 0 4px; background: var(--line-soft); }
.editor-pop { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line-soft); background: var(--paper); }
.editor-pop input { flex: 1 1 200px; width: auto; padding: 6px 10px; font-size: 14px; }
.editor-pop button { padding: 6px 12px; font-size: 14px; }
.editor-pop .error { min-height: 0; }
/* 처음 높이 180px, 내용에 따라 480px까지 늘고 그 뒤로는 칸 안에서 스크롤한다 */
.editor-area { min-height: 180px; max-height: 480px; overflow-y: auto; padding: 12px 14px; outline: none; }
.editor-area:empty::before { content: '내용을 입력하세요'; color: var(--ink-soft); }
.editor-area img { cursor: default; }
.editor-area .yt-embed::after { content: '▶ YouTube 영상'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 15px; }

@media (max-width: 640px) {
  /* 휴대폰: 윗줄에 분류와 제목, 아랫줄 왼쪽에 날짜·오른쪽에 이름 */
  .board-head, .board-no { display: none; }
  .board-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'title title' 'date author'; gap: 4px 8px; padding: 12px 6px; }
  .board-title { grid-area: title; }
  .board-date { grid-area: date; text-align: left; }
  .board-author { grid-area: author; text-align: right; font-size: 13px; color: var(--ink-soft); }
  .board-form-head { grid-template-columns: minmax(0, 1fr); }
  .board-post, .board-form { padding: 16px; }
  /* 펼친 검색칸은 탭 첫 줄 전체를 덮는다 */
  .board-tabs.search-open .board-search { width: 100%; }
}

/* ---------- 상세 패널 ---------- */

.panel {
  width: 380px;
  flex: none;
  overflow-y: auto;
  background: var(--card);
  border-left: 1px solid var(--line-soft);
  padding: 20px;
  display: grid;
  gap: 18px;
  align-content: start;
  position: relative;
}
.panel .close { position: absolute; top: 10px; right: 10px; border: 0; background: none; font-size: 26px; line-height: 1; padding: 4px 10px; }
.panel-head { display: flex; gap: 16px; align-items: flex-start; padding-right: 28px; }
.panel-head h2 { font-size: 24px; }
.panel-head > div:last-child { display: grid; gap: 6px; }
.portrait.big { width: 150px; flex: none; border-radius: 10px; cursor: pointer; }
.portrait.big .initial { font-size: 36px; }
.drop-hint {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(43, 38, 32, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  padding: 6px 8px;
  text-align: center;
}
.info { display: grid; gap: 10px; }
.field { display: grid; gap: 3px; }
.field > span { font-size: 13px; color: var(--ink-soft); }
.field p { white-space: pre-wrap; }
.info button { justify-self: start; }
/* 태어난 날은 가로 절반만 쓰고, 오른쪽 절반에 음력 생일을 보여준다 */
.date-row, .half-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.half-row input[name='hanja'] { font-family: var(--serif); }
/* 한자 후보: 큰 글자 옆에 뜻과 음 */
.hanja-help { display: grid; gap: 4px; }
.hanja-help:empty { display: none; }
.hanja-list { list-style: none; margin: 0; padding: 4px; max-height: 248px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.hanja-list li { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.hanja-list li.active, .hanja-list li:hover { background: var(--seal-soft); }
.hanja-list strong { flex: none; font-family: var(--serif); font-size: 26px; font-weight: 400; line-height: 1.15; }
.hanja-list span { min-width: 0; font-size: 14px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hanja-help .hint { font-size: 12px; line-height: 1.4; }
/* 이름 옆에 작게 붙는 한자 이름 */
.panel-head h2 .hanja { margin-left: 8px; font-size: 17px; font-weight: 400; color: var(--ink-soft); white-space: nowrap; }
.date-selects { display: flex; gap: 4px; }
.date-selects select { flex: 1 1 0; min-width: 0; padding: 9px 2px 9px 6px; font-size: 15px; }
.date-selects select:first-child { flex-grow: 1.5; }
.lunar-value { font-family: var(--serif); font-size: 16px; line-height: 1.3; white-space: nowrap; }
.lunar-value:not(:empty) { padding: 9px 0; }
.date-row .hint { font-size: 12px; line-height: 1.4; }
.date-row .hint:empty { display: none; }
.panel h3 { font-size: 17px; }

/* 관계 (촌수 · 호칭) — kinship.js */
.kin { display: grid; gap: 4px; padding: 12px 14px; border-radius: 10px; background: var(--paper); }
.kin-line { font-size: 16px; line-height: 1.5; word-break: keep-all; }
.kin-line strong { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--seal); }
.kin-line.back { font-size: 15px; color: var(--ink-soft); }
.kin-line.back strong { font-size: 16px; color: var(--ink); }
.kin-finder { display: grid; gap: 6px; margin-top: 8px; }
.kin-finder .tag-suggest { margin: 0; }
.kin-result { display: grid; gap: 2px; }
.kin-result:empty { display: none; }

/* 성별 입력 (관리자) */
.genders-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.genders-list { max-height: 60vh; overflow-y: auto; border-top: 1px solid var(--line-soft); }
.gender-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line-soft); }
.gender-row strong { font-family: var(--serif); font-size: 17px; margin-right: 8px; }
.gender-row .hint { font-size: 13px; }
.gender-pick { display: flex; gap: 6px; flex: none; }
.gender-pick button { min-width: 64px; padding: 8px 12px; font-size: 15px; }
.gender-pick button.active { background: var(--ink); border-color: var(--ink); color: var(--card); }
.modal label.check.genders-parents { flex-wrap: wrap; white-space: normal; font-size: 15px; }
.genders-parents .hint { font-size: 13px; }

.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.album figure { margin: 0; position: relative; }
.album img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; cursor: zoom-in; }
.album figcaption { display: flex; gap: 4px; margin-top: 4px; }
.album figcaption button { flex: 1; padding: 3px 0; font-size: 12px; border-radius: 6px; }
.album-add {
  aspect-ratio: 1;
  border: 1px dashed var(--ink-soft);
  background: var(--paper);
  font-size: 26px;
  line-height: 1.1;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--ink-soft);
}
.album-add small { font-size: 12px; }

.manage { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.manage button { font-size: 14px; }
.manage .danger { margin-left: auto; }
.updated { font-size: 13px; }

/* ---------- 창 ---------- */

.modal {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 24px;
  width: min(380px, calc(100vw - 32px));
}
.modal.wide { width: min(940px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(43, 38, 32, 0.55); }
.modal h2 { font-size: 20px; margin-bottom: 8px; }
.modal form, .modal { display: none; }
.modal[open] { display: grid; gap: 12px; }
.modal[open] form:not(.user-row) { display: grid; gap: 12px; }
.modal label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

#crop-canvas {
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: move;
  touch-action: none;
}
#crop-zoom { padding: 0; border: 0; background: none; }

/* 사진 올리기·고치기 창. 어른들이 보기 편하게 글씨를 조금 크게 */
.photo-modal { width: min(520px, calc(100vw - 32px)); }
.photo-modal:focus-visible { outline: none; }
.photo-drop { width: 100%; padding: 16px; border: 1px dashed var(--ink-soft); background: var(--paper); display: grid; gap: 2px; justify-items: center; font-size: 17px; }
.photo-drop small { font-size: 13px; color: var(--ink-soft); }
.photo-previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; max-height: 190px; overflow-y: auto; padding: 6px 6px 0 0; }
.photo-previews:empty { display: none; }
.photo-previews figure { position: relative; margin: 0; width: 72px; }
.photo-previews img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; display: block; }
.photo-previews figcaption { margin-top: 2px; font-size: 11px; color: var(--ink-soft); text-align: center; white-space: nowrap; }
.photo-previews figure button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; line-height: 1; }
.photo-previews figure.single { width: 120px; }
.photo-previews figure.single img { width: 120px; height: 120px; }
/* 여러 장 올리기: 사진마다 한 줄 (사진, 연·월·일 칸) */
/* 목록을 따로 스크롤하지 않고 창 전체가 함께 내려가게 한다 (스크롤 영역이 둘이면 헷갈린다) */
.photo-previews.rows { display: grid; gap: 8px; max-height: none; overflow: visible; }
.upload-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 6px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fff; }
.upload-row.invalid { border-color: var(--seal); box-shadow: 0 0 0 1px var(--seal); }
.upload-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.upload-row .date-fields { gap: 4px 8px; }
.modal .upload-row .date-fields label { font-size: 15px; }
.upload-row .date-fields input { width: 48px; padding: 6px 4px; font-size: 16px; }
.upload-row .date-fields input.year { width: 68px; }
.upload-row .hint { display: block; margin-top: 2px; font-size: 12px; }
.upload-row .remove { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; line-height: 1; }
#photo-pick-hint:empty { display: none; }
#photo-pick-hint { margin-top: 6px; }

.date-fields { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.date-fields legend, .field-title { display: block; padding: 0; margin-bottom: 6px; font-size: 17px; font-family: var(--serif); font-weight: 600; color: var(--ink); }
.modal .date-fields label { display: flex; align-items: center; gap: 5px; font-size: 16px; color: var(--ink); }
.date-fields input { width: 62px; padding: 8px 6px; font-size: 18px; text-align: center; }
.date-fields input[name='year'] { width: 88px; }

/* "누가 나왔나요?": 고른 사람은 이름표로 쌓이고 그 뒤에 이어서 친다 */
.tag-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 48px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: text; }
.tag-box:focus-within { outline: 2px solid var(--seal); outline-offset: 2px; }
.tag-chip { display: inline-flex; align-items: center; padding: 3px 2px 3px 12px; border-radius: 999px; background: var(--seal-soft); font-family: var(--serif); font-size: 17px; }
.tag-chip button { border: 0; background: none; padding: 0 8px; font-size: 18px; line-height: 1; color: var(--ink-soft); }
.tag-typing { position: relative; flex: 1 1 130px; min-width: 130px; }
.tag-input, .tag-ghost { padding: 5px 2px; font-size: 18px; line-height: 1.4; }
.tag-input { position: relative; width: 100%; border: 0; border-radius: 0; background: transparent; }
.tag-input:focus-visible { outline: none; }
/* 흐린 제안 글씨. 친 글자만큼 자리를 비우고 그 뒤에 나머지를 이어 보여준다 */
.tag-ghost { position: absolute; inset: 0; white-space: pre; overflow: hidden; color: #b5aa96; pointer-events: none; }
.tag-ghost-typed { visibility: hidden; }
.tag-suggest { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.tag-suggest li { display: flex; align-items: baseline; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.tag-suggest li.active, .tag-suggest li:hover { background: var(--seal-soft); }
.tag-suggest strong { font-family: var(--serif); font-size: 18px; font-weight: 600; white-space: nowrap; }
.tag-suggest span { font-size: 13px; color: var(--ink-soft); }
.tag-hint { min-height: 1.5em; margin-top: 4px; }

#users-list { display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; }
.modal[open] .user-row {
  display: grid;
  grid-template-columns: 116px 96px 124px 150px auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.user-row strong { font-family: var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row input, .user-row select { padding: 7px 8px; font-size: 14px; }
.user-row button { padding: 7px 10px; font-size: 14px; white-space: nowrap; }
#user-add { padding-top: 12px; border-top: 1px solid var(--line-soft); }
/* 계정 추가 줄에는 "돌아가신 날" 체크와 삭제 단추가 없으므로 그 자리를 비밀번호 칸과 추가 단추가 차지한다 */
#user-add [name='password'] { grid-column: 5 / 7; }
#user-add button { grid-column: 7 / 9; }
.modal label.check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink); white-space: nowrap; cursor: pointer; }
input[type='checkbox'] { width: auto; margin: 0; }
input[type='checkbox']:disabled + *, .check:has(input:disabled) { color: var(--line); cursor: default; }

#categories-list { display: grid; gap: 8px; }
.modal[open] form.category-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; gap: 6px; align-items: center; }
.modal[open] form#category-add { grid-template-columns: minmax(0, 1fr) auto; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.category-row input { padding: 7px 10px; font-size: 15px; }
.category-row button { padding: 7px 10px; font-size: 14px; white-space: nowrap; }
button:disabled { opacity: 0.45; cursor: default; }

/* 사진 크게 보기: 화면 전체를 덮고 좌우로 넘긴다 */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  overflow: hidden;
  background: rgba(24, 20, 16, 0.95);
  color: #fff;
  /* 휴대폰에서 누를 때 화면이 파랗게 덮이거나 글자가 선택되는 것을 막는다 */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}
/* 포커스는 창 자체에 둔다(app.js). Tab 키로 단추를 옮겨 다닐 때의 테두리는 어두운 바탕에 맞춰 흰색으로 */
.lightbox:focus-visible { outline: none; }
.lightbox :focus-visible { outline-color: #fff; }
.lb-stage { position: absolute; inset: 12px 12px 64px; }
.lb-stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lightbox button, .lb-download { position: absolute; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; line-height: 1; padding: 0; }
.lightbox button:hover, .lb-download:hover { background: rgba(255, 255, 255, 0.26); }
.lb-close { top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%; font-size: 28px; }
.lightbox .lb-edit, .lb-download { top: 10px; height: 44px; padding: 0 16px; border-radius: 22px; font-size: 15px; }
.lightbox .lb-edit { right: 64px; }
.lb-download { left: 10px; display: flex; align-items: center; text-decoration: none; }
.lb-prev, .lb-next { top: calc(50% - 24px); transform: translateY(-50%); width: 48px; height: 72px; border-radius: 10px; font-size: 40px; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
/* 여러 사람이 나온 사진은 이름이 길어지므로 두 줄까지 보여준다 */
.lb-info {
  position: absolute;
  inset: auto 0 0;
  height: 64px;
  padding: 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
}
.lb-caption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-align: center; word-break: keep-all; }
.lb-count { font-variant-numeric: tabular-nums; white-space: nowrap; color: rgba(255, 255, 255, 0.6); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--ink);
  color: var(--card);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 15px;
  max-width: calc(100vw - 32px);
}

/* ---------- 휴대폰 ---------- */

@media (max-width: 760px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar h1 { font-size: 17px; flex: 1 1 0; min-width: 0; }
  /* 첫 줄에 제목과 계정 메뉴, 둘째 줄에 메뉴 두 덩어리를 같은 폭으로 */
  .menu { order: 1; }
  .views { order: 2; flex: 1 0 100%; gap: 10px; }
  .segmented { flex: 1; }
  .segmented button { flex: 1; padding: 7px 4px; }
  .zoom { order: 3; }
  .panel { position: fixed; inset: 0; z-index: 30; width: auto; border-left: 0; }
  .modal[open] .user-row { grid-template-columns: 1fr 1fr; }
  #user-add [name='password'], #user-add button { grid-column: auto; }
  .row { gap: 10px; margin-left: calc(var(--depth) * 12px); padding-left: 10px; }
  .row .card { --card-w: 52px; }
  .lb-stage { inset: 0 0 64px; }
  .lb-prev, .lb-next { width: 40px; height: 60px; font-size: 32px; background: rgba(0, 0, 0, 0.3) !important; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px 8px; }
  .gallery-names button { font-size: 14px; }
  .gallery-bar { flex-wrap: wrap; }
  .gallery-search { flex: 1 0 100%; max-width: none; margin-right: 0; }
  /* 올리기 단추 둘은 한 줄을 나눠 쓰고, 연도 · 가족 고르기는 그 아래 줄에 */
  .gallery-uploads { flex: 1 0 100%; }
  .gallery-uploads .primary { flex: 1; }
  .upload-row { gap: 8px; }
  .upload-row img { width: 56px; height: 56px; }
  .upload-row .date-fields input { width: 42px; }
  .upload-row .date-fields input.year { width: 60px; }
  /* 올리기 단추, 연도, 가족이 한 줄에 들어가게 */
  .gallery-bar { gap: 8px; }
  .gallery-bar select { flex: 1 1 0; min-width: 0; padding: 9px 6px; }
  /* 연·월·일 칸이 한 줄에 들어가게 */
  .date-fields { gap: 6px 10px; }
  .date-fields input { width: 54px; }
  .date-fields input[name='year'] { width: 80px; }
}
