:root {
  --ink: #22362d;
  --ink-soft: #5f6f65;
  --green: #2b4d3d;
  --green-deep: #1d382b;
  --sage: #a8b7a2;
  --cream: #f8f4e9;
  --paper: #fffdf7;
  --linen: #ebe6d9;
  --clay: #b46d4d;
  --line: #d6d7c9;
  --shadow: 0 22px 65px rgba(36, 50, 39, 0.13);
  color: var(--ink);
  background: var(--cream);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--cream); scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  line-height: 1.7;
  background:
    radial-gradient(circle at 15% 30%, rgba(168, 183, 162, 0.17), transparent 28rem),
    var(--cream);
}

button, input, select { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, label:has(input:focus-visible) { outline: 3px solid #cf8d66; outline-offset: 3px; }

.section-shell { width: min(1200px, calc(100% - 48px)); margin: 0 auto; }

.hero {
  min-height: 500px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #f9f4e8;
  background: #304637 url("./assets/family-album-desk.jpg") center 42% / cover no-repeat;
}

.hero__wash {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, rgba(22, 48, 36, 0.95) 0%, rgba(29, 56, 43, 0.72) 45%, rgba(37, 58, 42, 0.3) 100%);
}

.hero__content { width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 98px 0 100px; }

.eyebrow, .section-kicker, .tiny-label { margin: 0; letter-spacing: 0.17em; font-size: 0.7rem; font-weight: 800; }
.eyebrow { color: #cbd8c4; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -0.04em; line-height: 1.25; }
h1 { margin: 26px 0 26px; font-family: Georgia, "Yu Mincho", serif; font-size: clamp(3.3rem, 7.6vw, 7rem); font-weight: 500; line-height: 0.98; }
h1 span { color: #d8e1ce; }
h2 { font-family: Georgia, "Yu Mincho", serif; font-size: clamp(1.75rem, 3.2vw, 2.8rem); font-weight: 500; }
h3 { font-size: 1.05rem; }
.hero__lead { max-width: 30rem; margin-bottom: 30px; color: #e4eadc; font-size: 1.08rem; }
.hero__privacy { display: inline-flex; align-items: center; gap: 9px; margin: 0; padding: 9px 13px; border: 1px solid rgba(224, 235, 214, 0.35); border-radius: 999px; color: #e3eddb; font-size: 0.85rem; }
.hero__privacy span { font-size: 1.15rem; }
.hero__stamp { position: absolute; right: clamp(24px, 8vw, 130px); bottom: 54px; color: rgba(242, 233, 203, 0.75); font-family: Georgia, "Yu Mincho", serif; font-size: 1.4rem; line-height: 1.35; writing-mode: vertical-rl; transform: rotate(5deg); }

.intro { display: flex; justify-content: space-between; gap: 64px; align-items: end; padding: 100px 0 66px; }
.intro h2 { margin: 13px 0 0; }
.section-kicker { color: var(--clay); }
.intro__copy { width: min(100%, 31rem); margin: 0 0 0 auto; color: var(--ink-soft); }

.workspace { display: grid; grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr); gap: 22px; align-items: start; }
.controls-column { display: grid; gap: 22px; }
.panel, .preview-panel { border: 1px solid rgba(71, 91, 72, 0.13); border-radius: 4px; box-shadow: var(--shadow); }
.panel { padding: 28px; }
.panel--cream { background: var(--paper); }
.panel--linen { background: #e8e3d6; box-shadow: none; }
.panel__heading, .preview-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.panel h2, .preview-panel h2 { margin: 8px 0 24px; font-size: 1.85rem; }
.counter, .tiny-label { color: var(--ink-soft); font-size: 0.76rem; white-space: nowrap; }
.counter { padding: 6px 9px; border: 1px solid var(--line); border-radius: 3px; background: #faf8f0; }
.tiny-label { padding-top: 9px; }

.stack-form label, .relation-form label { display: grid; gap: 6px; color: var(--ink); font-size: 0.82rem; font-weight: 700; }
.required { color: var(--clay); font-size: 0.68rem; letter-spacing: 0.05em; }
.inline-form { display: flex; gap: 8px; }
input[type="text"], select { width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid #bfc8bc; border-radius: 3px; background: #fffefa; color: var(--ink); font-size: 16px; }
select { appearance: auto; }
.field-note { margin: 8px 0 0; color: var(--ink-soft); font-size: 0.76rem; line-height: 1.55; }
.button { min-height: 46px; padding: 8px 15px; border-radius: 3px; font-size: 0.85rem; font-weight: 800; white-space: nowrap; transition: transform 140ms ease, background 140ms ease; }
.button:hover, .action-card:hover { transform: translateY(-2px); }
.button--primary { border: 1px solid var(--green); background: var(--green); color: #fffdf7; }
.button--primary:hover { background: var(--green-deep); }
.button--outline { width: 100%; border: 1px solid #657761; background: transparent; color: var(--green-deep); }
.button--outline:hover { background: rgba(255, 255, 255, 0.5); }

.people-list { display: grid; gap: 8px; max-height: 380px; margin: 23px 0 0; padding: 0; overflow: auto; list-style: none; }
.person-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 45px; padding: 8px 10px; border: 1px solid #e0e0d5; background: #faf8f0; }
.person-row__name { min-width: 0; overflow: hidden; color: var(--ink); font-size: 0.91rem; text-overflow: ellipsis; white-space: nowrap; }
.person-row__name::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: var(--sage); vertical-align: 1px; }
.delete-person { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: #8a5b4d; font-size: 0.76rem; }
.delete-person:hover { text-decoration: underline; }
.empty-people { margin: 22px 0 0; color: var(--ink-soft); font-size: 0.82rem; }

.relation-form { display: grid; gap: 12px; }
.relation-form h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-divider { height: 1px; margin: 25px 0; background: rgba(74, 91, 75, 0.2); }

.preview-panel { min-width: 0; overflow: hidden; background: #fdfbf4; }
.preview-heading { padding: 28px 30px 18px; }
.preview-panel h2 { margin-bottom: 0; }
.legend { display: flex; flex-wrap: wrap; justify-content: end; gap: 9px 14px; padding-top: 9px; color: var(--ink-soft); font-size: 0.7rem; }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-line { display: inline-block; width: 23px; height: 0; border-top: 2px solid var(--green); }
.legend-line--dash { border-top-style: dashed; border-color: var(--clay); }
.legend-line--spouse { border-color: #9ca78d; border-top-width: 3px; }
.diagram-scroll { max-width: 100%; overflow: auto; border-top: 1px solid #e5e4d9; border-bottom: 1px solid #e5e4d9; background: radial-gradient(circle at 15% 20%, rgba(181, 194, 168, 0.14), transparent 25rem), #fffef9; }
#family-svg { display: block; min-width: 440px; min-height: 200px; }
.svg-card { fill: #fffffb; stroke: #b9c7b7; stroke-width: 1.5; }
.svg-card--adoptive { fill: #fff9f3; stroke: #d9ae8e; }
.svg-card-name { fill: #294436; font-size: 13px; font-weight: 700; }
.print-svg .svg-card-name { font-size: 14px; }
.svg-card-meta { fill: #879489; font-size: 10px; letter-spacing: 0.12em; }
.svg-edge-parent { stroke: #557360; stroke-width: 2; fill: none; }
.svg-edge-adoptive { stroke: #bc7958; stroke-dasharray: 7 5; }
.svg-edge-spouse { stroke: #9da994; stroke-width: 3; }
.svg-edge-label { fill: #748176; font-size: 10px; }
.empty-hint { padding: 50px 28px; color: var(--ink-soft); text-align: center; }
.relationship-summary { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 30px 22px; }
.summary-chip { padding: 5px 8px; border: 1px solid #d9ddcf; border-radius: 2px; color: var(--ink-soft); font-size: 0.73rem; }
.print-pages { display: none; }

.actions { display: grid; grid-template-columns: 0.6fr 1.4fr; gap: 42px; align-items: start; padding: 106px 0 92px; }
.actions__intro h2 { margin: 12px 0 10px; }
.actions__intro p:last-child { max-width: 18rem; margin: 0; color: var(--ink-soft); font-size: 0.86rem; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.action-card { display: grid; min-height: 135px; padding: 18px; border: 1px solid #cfd7c9; border-radius: 3px; background: #fbf9f1; color: var(--ink); text-align: left; box-shadow: 0 8px 20px rgba(36, 50, 39, 0.05); transition: transform 140ms ease, background 140ms ease; }
.action-card:hover { background: #fffefa; }
.action-icon { display: block; color: var(--clay); font-family: Georgia, serif; font-size: 1.5rem; line-height: 1; }
.action-card strong { align-self: end; padding-top: 12px; font-size: 0.85rem; }
.action-card small { color: var(--ink-soft); font-size: 0.67rem; line-height: 1.4; }
.action-card--label { cursor: pointer; }
.action-card--label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.action-card--danger { border-color: #dfc6ba; color: #7d4e41; }

.limits { display: flex; gap: 18px; align-items: start; max-width: 840px; padding: 22px 25px; border-top: 1px solid #cfd7c9; border-bottom: 1px solid #cfd7c9; }
.limits__mark { display: grid; flex: 0 0 29px; width: 29px; height: 29px; place-items: center; border-radius: 50%; background: var(--green); color: #f9f4e8; font-family: Georgia, serif; }
.limits h2 { margin: 1px 0 6px; font-size: 1.05rem; font-family: inherit; font-weight: 800; letter-spacing: 0; }
.limits p { margin: 0; color: var(--ink-soft); font-size: 0.79rem; }

.site-footer { margin-top: 90px; background: var(--green-deep); color: #cbd8c4; }
.site-footer__inner { display: flex; justify-content: space-between; gap: 20px; padding: 24px 0; font-family: Georgia, "Yu Mincho", serif; font-size: 0.85rem; }
.status { position: fixed; right: 20px; bottom: 20px; z-index: 10; max-width: min(360px, calc(100% - 40px)); padding: 12px 15px; border: 1px solid #becdbd; border-radius: 3px; background: #f7fbf1; color: var(--ink); box-shadow: var(--shadow); font-size: 0.82rem; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity 160ms ease, transform 160ms ease; }
.status.is-visible { opacity: 1; transform: translateY(0); }
.status.is-error { border-color: #d8ac99; background: #fff3ed; color: #783f32; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .controls-column { grid-template-columns: 1fr 1fr; align-items: start; }
  .actions { grid-template-columns: 1fr; gap: 24px; }
  .actions__intro p:last-child { max-width: 34rem; }
}

@media (max-width: 680px) {
  .section-shell, .hero__content { width: min(100% - 30px, 1200px); }
  .hero { min-height: 460px; }
  .hero__content { padding: 70px 0 90px; }
  .hero__stamp { right: 18px; bottom: 28px; font-size: 1.1rem; }
  .intro { display: block; padding: 65px 0 42px; }
  .intro__copy { width: auto; margin: 23px 0 0; }
  .controls-column { grid-template-columns: 1fr; }
  .panel, .preview-heading { padding: 22px; }
  .legend { justify-content: start; padding-top: 0; }
  .preview-heading { display: block; }
  .preview-panel h2 { margin-bottom: 17px; }
  .relationship-summary { padding-left: 22px; padding-right: 22px; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .actions { padding: 72px 0 60px; }
  .status {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    bottom: auto;
    max-width: calc(100% - 24px);
  }
}

@media (max-width: 390px) {
  .inline-form { display: grid; grid-template-columns: 1fr; }
  .button--primary { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
  h1 { font-size: 3.25rem; }
  .hero__privacy { align-items: flex-start; border-radius: 4px; }
  .site-footer__inner { display: block; }
  .site-footer__inner span { display: block; }
  .site-footer__inner span + span { margin-top: 8px; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root { background: #fff; }
  body { background: #fff; }
  .hero, .intro, .controls-column, .actions, .limits, .site-footer, .status, .preview-panel, .preview-heading .legend, .relationship-summary { display: none !important; }
  .section-shell { width: 100%; }
  .workspace { display: block; margin: 0; }
  .print-pages { display: block !important; width: 100%; }
  .print-page { width: 100%; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-svg { display: block; width: 100%; height: auto; max-width: 100%; min-width: 0; aspect-ratio: 1320 / 900; }
}
