/* css/style.css — 큰 글씨·큰 버튼·높은 대비 (연령대 높은 사용자 기준) */
:root {
  --navy: #1e3a5f;
  --navy-dark: #12263f;
  --gold: #c9973f;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #d9dee6;
  --text: #1c2431;
  --muted: #5f6b7a;
  --danger: #d0342c;
  --ok: #1b7f3b;
  --focus: #2f7de1;
  --radius: 10px;
  --fs: 17px;
  --panel-w: 540px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Nanum Gothic', sans-serif;
  font-size: var(--fs); line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
h1, h2, h3, p { margin: 0; }

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; border-radius: 10px; background: var(--gold); color: var(--navy-dark); font-weight: 800; font-size: 26px; display: grid; place-items: center; }
.brand h1 { font-size: 21px; font-weight: 700; }
.version { font-size: 12px; font-weight: 500; opacity: .7; margin-left: 6px; }
.tagline { font-size: 13px; opacity: .85; }
.toolbar { flex: 1 1 auto; display: flex; gap: 14px 24px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.tgroup { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tgroup.quiet .tb { min-height: 36px; padding: 4px 10px; font-size: 14px; font-weight: 500; border-color: rgba(255,255,255,.2); background: transparent; opacity: .85; }
.tgroup.quiet .tb:hover { background: rgba(255,255,255,.14); opacity: 1; }
.tgroup.main { margin-left: auto; }
.tsep { width: 1px; height: 28px; background: rgba(255,255,255,.3); margin: 0 6px; }
.tb {
  min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.08); color: #fff; font-size: 16px; font-weight: 600;
}
.tb:hover { background: rgba(255,255,255,.18); }
.tb:disabled { opacity: .4; cursor: default; }
.tb.primary { background: var(--gold); color: var(--navy-dark); border-color: var(--gold); }
.tb.primary:hover { background: #dcab55; }
.tb:focus-visible, .zb:focus-visible, button:focus-visible { outline: 3px solid #ffd479; outline-offset: 2px; }

/* ---------- 본문 2단 ---------- */
.layout { display: grid; grid-template-columns: var(--panel-w) 1fr; height: calc(100vh - 66px); min-height: 480px; }
.panel { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 10px 12px 60px; }
.preview-wrap { display: flex; flex-direction: column; min-width: 0; }
.preview-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.preview-title { font-weight: 700; color: var(--navy); }
.save-state { font-size: 13px; color: var(--muted); flex: 1; }
.zoom { display: flex; align-items: center; gap: 4px; }
.zb { min-width: 40px; min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; color: var(--navy); }
.zb.wide { font-size: 15px; padding: 0 10px; }
.zb:hover { background: #eef2f8; }
.zoom-level { min-width: 52px; text-align: center; font-size: 14px; color: var(--muted); }
.view-opts { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; padding: 6px 16px; background: #fbfcfe; border-bottom: 1px solid var(--line); }
.view-opts-title { font-size: 14px; font-weight: 700; color: var(--muted); margin-right: 4px; }
.view-opts .chk { font-size: 15px; min-height: 34px; }
.view-hint { font-size: 13px; color: var(--muted); margin-left: auto; }
.stage svg g.node { cursor: grab; touch-action: none; }
.stage.dragging, .stage.dragging svg g.node { cursor: grabbing; user-select: none; }
/* 상속 순위 구분 머리글 */
.rank-group { border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: var(--radius); padding: 6px 8px 0; margin-bottom: 12px; background: #fafbfd; }
.rank-group.on { border-left-color: var(--ok); background: #f4fbf6; }
.rank-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; }
.rank-no { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 800; font-size: 15px; display: grid; place-items: center; }
.rank-group.on .rank-no { background: var(--ok); }
.rank-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; color: var(--navy); }
.rank-now { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--ok); background: #e3f5e8; border: 1px solid #b7e0c3; border-radius: 10px; padding: 3px 9px; white-space: nowrap; }
.rank-group .sec { background: #fff; }
.notice { font-size: 14px; color: #8a5a00; background: #fff8e6; border: 1px solid #f3dfa4; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.row-next { justify-content: flex-end; margin-top: 4px; }
.btn-next { min-height: 44px; padding: 6px 16px; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font-weight: 700; font-size: 15px; }
.btn-next:hover { background: var(--navy-dark); }
.preview { flex: 1; overflow: auto; padding: 16px; background: #e9edf2; }
.stage { display: inline-block; min-width: 100%; text-align: center; }
.stage svg { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.12); border-radius: 6px; max-width: none; }

/* ---------- 섹션 ---------- */
.sec { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: #fff; }
.sec-head {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 12px 14px; border: 0; background: #f6f8fb; border-radius: var(--radius); color: var(--navy); font-size: 18px; font-weight: 700;
}
.sec.open .sec-head { border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--line); }
.sec-title { flex: 1; }
.sec-count { font-size: 13px; font-weight: 600; background: var(--navy); color: #fff; border-radius: 12px; padding: 2px 9px; }
.sec-arrow { font-size: 16px; color: var(--muted); }
.sec-body { padding: 6px 8px 6px; }
.hint { font-size: 14px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.sub-title { font-size: 16px; color: var(--navy); margin: 8px 0 6px; padding-left: 4px; border-left: 4px solid var(--gold); }

/* ---------- 인물 카드: 한 사람 = 두 줄 ---------- */
/* 최상위 인물은 옅은 상자 하나로 감싸 사람 사이를 띄우고, 하위 인물은 그 안에서 구분선·들여쓰기로만 나눈다 */
.card { position: relative; padding: 10px 10px 8px; background: #fff; border: 1px solid #d9dfe8; border-radius: 10px; margin-bottom: 12px; }
.subs { margin: 8px 0 0 4px; border-left: 3px solid #d5dfec; padding-left: 6px; }  /* 단계마다 13px 들여쓰기 */
.subs .subs { border-left-color: #e6edf5; }
.subs .card { border: 0; border-radius: 0; border-top: 1px solid var(--line); margin-bottom: 0; padding: 10px 0 8px 2px; background: transparent; }
.subs .card:first-child { border-top: 0; padding-top: 4px; }
.l1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card.has-del > .l1 { padding-right: 54px; }   /* 오른쪽 위 삭제 버튼 자리 */
.rel { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--navy); background: #e9eef6; border-radius: 6px; padding: 5px 6px; white-space: nowrap; }
.in-name { flex: 1 1 72px; min-width: 72px; min-height: 44px; /* 줄바꿈 판단은 기준 폭(72px)으로, 남는 공간은 채운다 */ padding: 6px 10px; border: 1px solid #c8cfd9; border-radius: 8px; font-size: 18px; font-weight: 600; }
.l1 .segs .seg { min-width: 42px; padding: 0 6px; }
.l1 .btn-del { position: absolute; top: 12px; right: 10px; padding: 0 9px; font-size: 13px; }
.subs .card > .l1 .btn-del { right: 0; }
.subs .card:first-child > .l1 .btn-del { top: 6px; }
.in-name:required:placeholder-shown { border-color: var(--gold); }
.in-name:focus { outline: 3px solid rgba(47,125,225,.35); border-color: var(--focus); }
.fld-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fld-head label:first-child { flex: 0 0 auto; }
.chk-dead { display: flex; align-items: center; gap: 4px; min-height: 44px; font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap; }
.chk-dead input { width: 21px; height: 21px; margin: 0; }
.chk-dead:has(input:checked) { color: var(--danger); }
.btn-del { flex: 0 0 auto; min-height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid #f0c4c1; background: #fff5f4; color: var(--danger); font-size: 14px; font-weight: 700; }
.btn-del:hover { background: #ffe5e3; }
.l2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 8px; }
.l2 .fld-date { flex: 0 1 190px; min-width: 176px; }
.l2 .fld { flex: 1 1 120px; }
.l2 .fld-date { flex: 0 1 180px; min-width: 164px; } /* 'YYYY-MM-DD' 열 글자 + 달력 버튼이 항상 다 보이도록 */
.l2 .fld-date .date-wrap input[type="text"] { min-width: 118px; }
.l2 .fld label { font-size: 12px; }
.l2 .fld input[type="text"], .l2 .fld select { min-height: 40px; font-size: 16px; padding: 4px 8px; }
.date-wrap { display: flex; }
.date-wrap input[type="text"] { border-radius: 8px 0 0 8px; min-width: 0; }
.btn-cal { flex: 0 0 auto; width: 40px; min-height: 40px; padding: 0; border: 1px solid #c8cfd9; border-left: 0; border-radius: 0 8px 8px 0; background: #fff; color: var(--navy); display: grid; place-items: center; }
.btn-cal:hover { background: #eef2f8; }
.fld input.invalid { border-color: var(--danger); background: #fff5f4; }
.date-picker { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.btn-detail { flex: 0 0 auto; min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid #c8cfd9; background: #f6f8fb; color: var(--muted); font-size: 14px; white-space: nowrap; align-self: flex-end; }
.btn-detail.on { color: var(--navy); border-color: var(--navy); background: #fff; }
.l3 { margin-top: 6px; }
.l3.dates { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.l3.memo input { width: 100%; min-height: 40px; padding: 4px 10px; border: 1px solid #c8cfd9; border-radius: 8px; font-size: 15px; }
.l3 .fld-date { flex: 0 1 180px; min-width: 164px; }
.l3 .fld label { font-size: 12px; }
.l3 .fld input[type="text"] { min-height: 40px; font-size: 16px; padding: 4px 8px; }
.l4 { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; align-items: flex-end; }
.row-btns { gap: 8px; }
.fld { display: flex; flex-direction: column; gap: 3px; flex: 1 1 130px; min-width: 0; }
.fld-name { flex: 2 1 160px; }
.fld-wide { flex: 1 1 100%; }
.fld label { font-size: 13px; color: var(--muted); font-weight: 600; }
.fld input[type="text"], .fld select {
  min-height: 44px; padding: 6px 10px; border: 1px solid #c8cfd9; border-radius: 8px; background: #fff; width: 100%;
}
.fld input:focus, .fld select:focus { outline: 3px solid rgba(47,125,225,.35); border-color: var(--focus); }
.fld input:required:placeholder-shown { border-color: var(--gold); }
.fld-gender { flex: 0 0 auto; }
.segs { display: flex; }
.seg { min-width: 52px; min-height: 44px; border: 1px solid #c8cfd9; background: #fff; color: var(--muted); font-weight: 700; }
.seg:first-child { border-radius: 8px 0 0 8px; }
.seg:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.seg.on { background: var(--navy); color: #fff; border-color: var(--navy); }          /* 남 = 남색 */
.seg.on[data-value="F"] { background: #d9487a; border-color: #d9487a; }         /* 여 = 분홍 */
.fld-check { flex: 0 0 auto; justify-content: flex-end; }
.fld-check label { display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: 16px; color: var(--text); cursor: pointer; }
.fld-check input { width: 22px; height: 22px; }
.btn-add, .btn-sub {
  min-height: 44px; padding: 6px 14px; border-radius: 8px; border: 1px solid #b9c6d8; background: #f2f6fc; color: var(--navy); font-weight: 700; font-size: 15px;
}
.btn-add:hover, .btn-sub:hover { background: #e2ebf8; border-color: var(--navy); }
.btn-sub { min-height: 36px; font-size: 14px; padding: 4px 10px; background: #fff; }
.opts { gap: 6px 16px; }
.chk { display: flex; align-items: center; gap: 6px; min-height: 36px; font-size: 15px; cursor: pointer; }
.chk input { width: 20px; height: 20px; }

/* ---------- 상속분 표 ---------- */
.rank { font-size: 16px; color: var(--navy); margin-bottom: 8px; }
table.heirs { width: 100%; border-collapse: collapse; font-size: 15px; margin-bottom: 8px; }
table.heirs th, table.heirs td { border-bottom: 1px solid var(--line); padding: 7px 6px; text-align: left; vertical-align: top; }
table.heirs th { background: #f6f8fb; font-size: 13px; color: var(--muted); }
table.heirs td.share { white-space: nowrap; font-weight: 700; color: var(--ok); }
table.heirs small { color: var(--muted); font-weight: 400; }
.tag { font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.tag-limited { background: #e4ecfb; color: #1f5fbf; }
.notes, .warns { margin: 6px 0; padding-left: 20px; font-size: 14px; }
.notes li { color: #3b4a5e; margin-bottom: 4px; }
.warns li { color: var(--danger); margin-bottom: 4px; font-weight: 600; }
.disclaimer { font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; margin: 8px 0; }

/* ---------- 확인창 ---------- */
.dlg { border: 0; border-radius: 14px; padding: 0; width: min(92vw, 460px); box-shadow: 0 12px 40px rgba(0,0,0,.28); color: var(--text); }
.dlg::backdrop { background: rgba(18,38,63,.45); }
.dlg form { padding: 22px 24px 18px; }
.dlg h2 { font-size: 20px; color: var(--navy); margin-bottom: 10px; }
.dlg p { font-size: 17px; line-height: 1.55; white-space: pre-line; margin-bottom: 18px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 10px; }
.dlg-btn { min-height: 46px; min-width: 96px; padding: 8px 18px; border-radius: 10px; border: 1px solid #c8cfd9; background: #fff; font-size: 17px; font-weight: 700; color: var(--text); }
.dlg-btn:hover { background: #f2f5f9; }
.dlg-btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.dlg-btn.primary:hover { background: var(--navy-dark); }
.dlg-btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.dlg-btn.danger:hover { background: #b52a23; }

/* ---------- 알림 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--navy-dark); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 16px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; }
  .preview-wrap { min-height: 70vh; }
  .preview { min-height: 60vh; }
}

/* ---------- 인쇄: 종이 한 장에 맞춘 페이지만 ---------- */
.print-page { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { height: auto; background: #fff; }
  .topbar, .layout, .toast, .date-picker { display: none !important; }
  .print-page { display: block; }
  .print-page svg { width: 100%; height: auto; display: block; }
}
