/* Cây gia phả: những phần mà class Tailwind sẽ lặp lại (trường nhập, nút, chip, hộp thoại) và khung cùng các thẻ
   của cây, do family-chart vẽ (js/chart.js; stylesheet riêng của nó không được tải: chỉ hai rule nó cần nằm
   ở đây). Cùng bảng màu với shared/js/tailwind-theme.js. */

/* Trang không tải shared/css/app.css, và rule [hidden] riêng của Tailwind thua một utility display (flex,
   grid) trên cùng element: hidden phải thắng ở mọi nơi, như app.css làm. */
[hidden] { display: none !important; }

.gp-label { display: flex; flex-direction: column; gap: 6px; font-size: 0.875rem; font-weight: 500; color: #2b231e; }

.gp-field {
  width: 100%; min-width: 0; min-height: 44px;
  border: 1px solid #d7c8b7; border-radius: 14px; background: #faf6f0;
  padding: 10px 14px; font-size: 0.9rem; font-weight: 400; color: #2b231e;
}
.gp-field::placeholder { color: #71645a; }
.gp-field:focus { outline: none; border-color: #9c4728; box-shadow: 0 0 0 3px rgb(156 71 40 / 0.2); }

.gp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  border: 1px solid #d7c8b7; border-radius: 999px; background: #fff; padding: 9px 18px;
  font-size: 0.875rem; font-weight: 600; color: #2b231e; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.gp-btn:hover:not(:disabled) { border-color: #9c4728; }
.gp-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.gp-btn.is-primary { border-color: #9c4728; background: #9c4728; color: #fff; }
.gp-btn.is-primary:hover:not(:disabled) { background: #7a361d; border-color: #7a361d; }
.gp-btn.is-small { min-height: 40px; padding: 7px 14px; font-size: 0.82rem; }
.gp-btn.is-danger { border-color: #b3261e; color: #b3261e; background: transparent; }
.gp-btn.is-danger:hover:not(:disabled) { background: #fdecea; }
.gp-btn:focus-visible, .gp-chip:focus-visible, .gp-icon-btn:focus-visible { outline: 3px solid #f2b45a; outline-offset: 2px; }

.gp-link { font-size: 0.82rem; font-weight: 500; color: #7a361d; text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.gp-link:hover { color: #9c4728; }

.gp-icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 999px; border: 1px solid #d7c8b7; background: #faf6f0;
  font-size: 1.05rem; line-height: 1; color: #2b231e;
  transition: background 0.15s, border-color 0.15s;
}
.gp-icon-btn:hover { background: #f3ece2; border-color: #9c4728; }

.gp-segment { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #efe2d3; }
.gp-segment button {
  flex: 1 1 0; min-height: 40px; border-radius: 999px; padding: 8px 14px;
  font-size: 0.85rem; font-weight: 500; color: #65584e; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.gp-segment button[aria-pressed="true"] { background: #faf6f0; color: #2b231e; box-shadow: 0 1px 3px rgb(43 35 30 / 0.12); }
.gp-segment button:disabled { opacity: 0.45; cursor: not-allowed; }
/* Một ngày (js/date-field.js): nhãn của nó, cách nhập (chip nhỏ, khác với các đoạn chọn một giá trị), trường nhập,
   ngày viết bằng chữ; cách nhau để bốn phần không dính vào nhau. */
.gp-date { display: flex; flex-direction: column; gap: 8px; }
.gp-date-label { font-size: 0.875rem; font-weight: 500; color: #2b231e; }
.gp-date-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-date-said { margin-top: -2px; font-size: 0.75rem; color: #65584e; }
.gp-date-said:empty { display: none; }
.gp-date-modes button {
  min-height: 36px; border: 1px solid #d7c8b7; border-radius: 999px; background: #fff; padding: 5px 12px;
  font-size: 0.8rem; font-weight: 500; color: #65584e; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.gp-date-modes button:hover:not(:disabled) { border-color: #9c4728; }
.gp-date-modes button[aria-pressed="true"] { border-color: #2b231e; background: #2b231e; color: #faf6f0; }
.gp-date-modes button:disabled { opacity: 0.45; cursor: not-allowed; }
.gp-date-modes button:focus-visible { outline: 3px solid #f2b45a; outline-offset: 2px; }
.gp-field[type="date"] { appearance: none; -webkit-appearance: none; text-align: left; }
.gp-field[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* Các nút lọc: một hàng cuộn ngang trên điện thoại. */
.gp-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.gp-chip {
  flex: 0 0 auto; min-height: 40px; border: 1px solid #d7c8b7; border-radius: 999px; background: transparent;
  padding: 7px 16px; font-size: 0.875rem; font-weight: 500; color: #2b231e; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.gp-chip:hover { border-color: #9c4728; }
.gp-chip[aria-pressed="true"] { background: #2b231e; border-color: #2b231e; color: #faf6f0; }
.gp-chips .gp-sep { flex: 0 0 1px; margin: 6px 2px; background: #d7c8b7; }

/* Khung của cây: giấy chấm bi; các nút zoom và một dòng về những gì đang hiện nằm trên đó. */
.gp-stage {
  position: relative; overflow: hidden; border: 1px solid #e8ded2; border-radius: 24px;
  background: radial-gradient(circle at 1px 1px, #e2cdb8 1px, transparent 1.4px) 0 0 / 22px 22px, #f3ece2;
}
.gp-chart { position: relative; display: flex; width: 100%; height: min(70vh, 640px); min-height: 420px; color: #2b231e; }
.gp-chart svg.main_svg { width: 100%; height: 100%; }
.gp-chart path.link { stroke: #c9b8a6; stroke-width: 1.5px; }
.gp-stage-msg {
  position: absolute; left: 12px; top: 12px; z-index: 2; max-width: calc(100% - 24px);
  border: 1px solid #e8ded2; border-radius: 12px; background: #fff; padding: 6px 12px;
  font-size: 0.82rem; color: #65584e; box-shadow: 0 14px 30px -18px rgb(43 35 30 / 0.45);
}
.gp-zoom { position: absolute; right: 12px; bottom: 12px; z-index: 2; display: grid; gap: 6px; justify-items: end; }
.gp-zoom button {
  min-width: 44px; height: 44px; border-radius: 14px; border: 1px solid #d7c8b7; background: #fff;
  padding: 0 12px; font-size: 1.1rem; font-weight: 600; color: #2b231e; box-shadow: 0 14px 30px -18px rgb(43 35 30 / 0.45);
}
.gp-zoom button.is-text { font-size: 0.82rem; }
.gp-fallback { padding: 24px; }
.gp-fallback ul { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Một thẻ của cây (family-chart đặt mỗi thẻ vào giữa chỗ của nó). */
.gp-chart div.card { cursor: pointer; line-height: 1.25; }
.gp-card {
  position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 8px;
  width: 158px; padding: 10px 10px 9px; border: 1px solid #d7c8b7; border-radius: 14px; background: #fff;
  color: #2b231e; text-align: left; box-shadow: 0 14px 30px -18px rgb(43 35 30 / 0.45);
  transition: opacity 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.gp-av {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: #efe2d3; font-size: 0.8rem; font-weight: 700; color: #2b231e;
}
.gp-card.is-f .gp-av:not(img) { background: #f6e6da; }
.gp-card.is-dead .gp-av { filter: grayscale(0.6); opacity: 0.75; }
.gp-name { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 0.82rem; font-weight: 600; }
.gp-years { display: block; font-size: 0.72rem; color: #65584e; font-variant-numeric: tabular-nums; }
.gp-pill {
  position: absolute; top: -10px; right: 8px; max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid #faf6f0; border-radius: 999px; background: #ffe4d4; padding: 1px 9px;
  font-size: 0.7rem; font-weight: 700; color: #7a361d;
}
.gp-card.is-me { border: 2px solid #e2683c; }
.gp-card.is-me .gp-pill { background: #9c4728; color: #fff; }
.gp-card.is-dim { opacity: 0.45; }
.gp-card.is-path { border: 2px solid #e2683c; box-shadow: 0 0 0 4px #ffe4d4, 0 14px 30px -18px rgb(43 35 30 / 0.45); }
.gp-card.is-pick { outline: 3px dashed #f2b45a; outline-offset: 3px; }

/* Bảng hai người. */
.gp-options {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 10; margin-top: 4px; max-height: 18rem; overflow-y: auto;
  border: 1px solid #d7c8b7; border-radius: 14px; background: #fff; padding: 4px; box-shadow: 0 24px 48px -24px rgb(43 35 30 / 0.35);
}
.gp-options button { display: block; width: 100%; border-radius: 10px; padding: 9px 12px; text-align: left; font-size: 0.875rem; }
.gp-options button:hover, .gp-options button:focus-visible { background: #f3ece2; outline: none; }
.gp-verdict { border-radius: 20px; background: #241c17; padding: 16px 18px; font-size: 1.05rem; line-height: 1.55; color: #f3ece2; }
.gp-verdict strong { font-weight: 600; color: #f2b45a; }
.gp-verdict .gp-sub { display: block; margin-top: 6px; font-size: 0.85rem; color: #c2b0a1; }
.gp-steps li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; }
.gp-steps .gp-dot { width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; background: #e2683c; }
.gp-steps .gp-who { font-weight: 600; }
.gp-steps .gp-who span { font-weight: 500; color: #7a361d; }
.gp-steps .gp-via { grid-column: 2; margin-left: -21px; border-left: 2px dotted #d7c8b7; padding: 2px 0 6px 19px; font-size: 0.82rem; color: #65584e; }

/* Phần chi tiết. */
.gp-photo { display: grid; place-items: center; width: 72px; height: 72px; flex-shrink: 0; overflow: hidden; border-radius: 50%; background: #efe2d3; font-size: 1.4rem; font-weight: 700; color: #2b231e; }
.gp-photo img { width: 100%; height: 100%; object-fit: cover; }
.gp-photo.is-small { width: 48px; height: 48px; font-size: 1rem; }
.gp-fact { border: 1px solid #e8ded2; border-radius: 16px; padding: 10px 12px; }
.gp-fact.is-call { border-color: transparent; background: #ffe4d4; }
.gp-fact-key { font-size: 0.75rem; font-weight: 600; color: #65584e; }
.gp-fact-value { font-size: 1rem; font-weight: 600; }
.gp-fact.is-call .gp-fact-value { color: #7a361d; }

.gp-dialog {
  width: min(34rem, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  border: 0; border-radius: 28px; padding: 24px; background: #faf6f0; color: #2b231e;
  box-shadow: 0 30px 60px -20px rgb(43 35 30 / 0.45);
}
.gp-dialog::backdrop { background: rgb(36 28 23 / 0.45); backdrop-filter: blur(2px); }
@media (max-width: 639px) {
  /* Điện thoại: một tấm trượt lên từ đáy màn hình. */
  .gp-dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 28px 28px 0 0; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
:root.phone-fit .gp-dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 28px 28px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .gp-card, .gp-btn, .gp-chip { transition: none; }
}
