:root {
  color-scheme: light;
  font-family: "Inter", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  color: #143454;
  background: #f8f5ed;
  --line: #dadfdc;
  --green: #123f67;
  --muted: #4b5e6f;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.125rem, 3vw, 1.48rem); letter-spacing: .02em; }
h2 { font-size: 1.13rem; }
h3 { font-size: .94rem; }
button, input, select, textarea { font: inherit; }
button, select, textarea, input:not([type=checkbox]) {
  min-height: 44px; border: 1px solid #c6d6da; border-radius: 9px;
  background: white; color: #143454;
}
button { padding: 8px 12px; cursor: pointer; font-weight: 650; font-size: .875rem; }
button:hover:not(:disabled) { background: #e6f3f0; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--green); color: white; border-color: var(--green); }
.primary:hover:not(:disabled) { background: #1b527e; }
:focus-visible { outline: 3px solid #268478; outline-offset: 3px; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner, main { width: min(100% - 48px, 1340px); margin-inline: auto; }
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 19px; }
.brand, .header-actions, .paper-actions, .row { display: flex; align-items: center; gap: 8px; }
.brand { gap: 12px; }
.brand p, .privacy, .paper-footer, .sub { color: var(--muted); font-size: .875rem; line-height: 1.55; }
.brand p { margin-top: 3px; }
.draft-tools { padding-block: 12px; }
.draft-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.draft-toggle { display: flex; align-items: center; min-height: 44px; padding-right: 8px; }
.draft-tools .privacy { margin-top: 4px; }
#draftStatus { font-weight: 650; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 350px); gap: 18px; align-items: start; }
.paper, .panel { min-width: 0; background: white; border: 1px solid var(--line); border-radius: 16px; }
.paper { overflow: hidden; }
.paper-header, .paper-footer { display: flex; justify-content: space-between; gap: 10px; padding: 14px 16px; }
.paper-header { align-items: center; border-bottom: 1px solid var(--line); }
.paper-header > div:first-child { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.zoom-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.zoom-tools button { min-width: 44px; }
#zoomLevel { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
#counts { color: var(--muted); font-size: .82rem; }
.canvas {
  position: relative; min-height: 480px; height: min(63vh, 660px); overflow: auto;
  overscroll-behavior: contain; background: radial-gradient(#cdd9d6 1px, #fffdfa 1px) 0 0 / 18px 18px;
}
#drawing { display: grid; min-width: 100%; min-height: 100%; width: max-content; place-items: start center; }
#drawing svg { display: block; }
#drawing [data-node] { cursor: grab; touch-action: none; }
#drawing [data-node]:active { cursor: grabbing; }
#drawing .selection { pointer-events: none; }
#drawing .canvas-background { fill-opacity: 0; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 16px; }
.empty h3 { font-size: 1.2rem; }
.empty p { color: var(--muted); font-size: .91rem; }
.empty-mark { display: grid; place-items: center; background: #e2f1eb; color: #206859; font-size: 1.25rem; width: 82px; height: 48px; border-radius: 12px; }
.paper-footer { border-top: 1px solid var(--line); align-items: start; }
.legend { flex: 0 0 auto; max-width: min(100%, 260px); }
summary { cursor: pointer; color: var(--green); font-weight: 650; }
.panel { padding: 17px; }
.person-picker { background: #e6f4ef; border-radius: 11px; padding: 12px; margin-block: 13px; }
.person-picker select { flex: 1; min-width: 0; }
label { display: grid; gap: 5px; font-size: .9rem; }
select, textarea, input:not([type=checkbox]) { width: 100%; padding: 8px; font-size: 1rem; min-width: 0; }
.person-picker label { margin-bottom: 7px; font-weight: 650; }
#controls section { padding-block: 13px; border-bottom: 1px solid var(--line); }
.action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.action-grid button { padding-inline: 2px; }
.add-person { margin-top: 8px; width: 100%; }
.relations { padding-top: 13px; }
.relation-actions { display: grid; gap: 6px; margin-block: 8px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 7px; overflow-wrap: anywhere; }
.list-item button { flex: 0 0 auto; }
#status { min-height: 1.5em; margin: 12px 0; color: var(--muted); overflow-wrap: anywhere; }
#status:not(:empty) { position: fixed; z-index: 2; bottom: 0; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); margin-bottom: 14px; padding: 8px 12px; background: #123f67; color: white; border-radius: 9px; box-shadow: 0 3px 12px #123f6733; pointer-events: none; }
dialog { width: min(570px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 15px; padding: 0; color: #143454; box-shadow: 0 16px 60px #132c4633; }
#batchEditor { width: min(750px, calc(100% - 24px)); }
dialog::backdrop { background: #132c4666; }
dialog form { padding: 16px; }
dialog h2 { margin-bottom: 12px; }
dialog label { margin-block: 8px; }
dialog label:has(input[type=checkbox]) { display: flex; align-items: center; min-height: 40px; }
input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--green); }
dialog .row { flex-wrap: wrap; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.batch-card { border: 1px solid var(--line); border-radius: 10px; margin-block: 10px; padding: 11px; }
.batch-setup, .batch-paired, .batch-person-fields, .batch-relationship-settings { display: grid; gap: 8px; align-items: end; }
.batch-setup { grid-template-columns: minmax(0, 1fr) minmax(100px, auto); }
.batch-paired, .batch-relationship-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.batch-person-fields { grid-template-columns: repeat(2, minmax(0, 1fr)) 80px; }
.batch-card { min-width: 0; }
.batch-card legend { font-weight: 700; }
.batch-card[data-guide-role="parent"] { border-color: #427d7a; background: #f3f8f7; }
.batch-card[data-guide-role] .batch-person-fields { grid-template-columns: 1fr; }
.batch-notes { align-items: start; }
.batch-flags { display: flex; flex-wrap: wrap; gap: 0 10px; }
dialog .batch-flags label { margin: 0; min-height: 32px; }
dialog .batch-card textarea { min-height: 42px; }
.batch-help { font-size: .9em; margin: 6px 0; }
#peopleSelection { padding: 8px 12px; }
#siblingOrderList { padding-left: 26px; }
#siblingOrderList li { margin: 6px 0; }
.sibling-order-row { display: flex; gap: 5px; align-items: center; padding: 4px; border: 1px solid var(--line); border-radius: 6px; }
.sibling-order-row button { padding-inline: 6px; }
.sibling-order-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
[data-sibling-drag] { display: grid; place-items: center; min-width: 30px; min-height: 40px; cursor: grab; touch-action: none; }
.sibling-dragging { opacity: .55; }
.sibling-drop-before { box-shadow: 0 -3px #427d7a; }
.sibling-drop-after { box-shadow: 0 3px #427d7a; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 420px) {
  .batch-person-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-notes, [data-parent-fields] { margin-block: 4px; }
}
#makeBatch { margin-block: 5px 9px; }
.dialog-actions { position: sticky; bottom: 0; background: white; padding-top: 9px; padding-bottom: 3px; border-top: 1px solid var(--line); }
.danger { color: #9d312e; }
p.danger:not(:empty) { margin: 9px 0; }
#deleteItem { margin-left: auto; }
@media (max-width: 780px) {
  .header-inner, main { width: calc(100% - 24px); }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .header-inner { flex-wrap: wrap; padding-block: 12px; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }
  .canvas { height: 310px; min-height: 0; }
  .paper-header, .paper-footer { padding: 8px; }
  .paper-actions { gap: 4px; }
  .paper-actions button { padding-inline: 6px; }
  .paper-header > div:first-child { display: grid; gap: 2px; }
  .paper-footer { display: block; }
  .legend { margin-top: 4px; }
}
@media (max-width: 420px) {
  .fields { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .draft-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.site-header { background: #fffdfa; border-bottom: 0; }
.header-inner { border-bottom: 2px solid transparent; border-image: linear-gradient(90deg, #244c79, #51a79e) 1; }
.draft-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.draft-bar button { flex-shrink: 0; }
.draft-menu { padding-block: 2px; }
.draft-menu summary { min-height: 38px; align-content: center; font-size: .86rem; }
.draft-menu[open] .draft-actions { padding-top: 6px; }
.zoom-tools { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
#drawing .selection { stroke: #138377; }
#personSearch { margin-top: clamp(16px, 10dvh, 100px); }
.search-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.search-heading h2 { margin: 0; }
#searchQuery { margin-block: 10px 6px; }
#searchResults { padding: 0; margin: 8px 0 0; list-style: none; overflow: auto; max-height: 54dvh; }
#searchResults button { width: 100%; text-align: left; margin-block: 2px; overflow-wrap: anywhere; }
#searchResults button[aria-current="true"] { background: #daf2e9; border-color: #69a89d; }
#searchResults small { display: block; color: var(--muted); margin-top: 3px; }
@media (max-width: 780px) {
  .header-inner { flex-wrap: nowrap; gap: 6px; }
  .header-actions { width: auto; flex: 0 0 auto; }
  .header-actions button { padding-inline: 8px; }
  .draft-tools { padding-block: 6px; }
  .canvas { height: clamp(355px, 53dvh, 560px); }
  .zoom-tools { gap: 4px; justify-content: center; }
  .zoom-tools button { padding-inline: 5px; }
  #zoomLevel { min-width: 35px; font-size: .8rem; }
}