:root {
  --ink: #17221d;
  --muted: #65716b;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --line: #dce2dd;
  --soft: #eef2ed;
  --green: #355f4b;
  --green-dark: #244536;
  --green-soft: #dfece4;
  --gold: #bd8b45;
  --danger: #a64038;
  --danger-soft: #f8e7e5;
  --shadow: 0 16px 44px rgba(24, 43, 34, 0.08);
  --header-height: 72px;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--green-dark); }
button, input, select, textarea { font: inherit; }
button, .button { -webkit-tap-highlight-color: transparent; }

.site-header {
  position: relative;
  z-index: 100;
  height: var(--header-height);
  padding: 0 clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark, .login-brand {
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 50%;
  font-family: Georgia, serif;
}

.brand-mark { width: 34px; height: 34px; font-size: 17px; }

.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav > a, .logout-form button {
  display: inline-flex;
  min-height: 38px;
  padding: 8px 13px;
  align-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}
.site-nav > a:hover, .logout-form button:hover, .site-nav > a.active { color: var(--ink); background: var(--soft); }
.logout-form { margin: 0 0 0 6px; padding-left: 6px; border-left: 1px solid var(--line); }
.nav-toggle { display: none; }

.page-shell { width: min(960px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 80px; }
.page-wide { width: min(1180px, calc(100% - 40px)); }
.narrow-page { width: min(650px, calc(100% - 40px)); }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 32px;
}
.page-heading h1, .empty-state h1, .confirmation-card h1, .login-panel h1 {
  margin: 4px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 50px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
}
.page-heading p, .section-heading p { margin: 0; color: var(--muted); }
.page-heading .form-context { max-width: 660px; margin-top: 8px; color: var(--green); font-size: 13px; }
.eyebrow { color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }

.button {
  display: inline-flex;
  min-height: 43px;
  padding: 10px 17px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #cbd3cd;
  border-radius: 11px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  transition: 150ms ease;
}
.button:hover { color: var(--ink); border-color: #aebbb3; box-shadow: 0 5px 16px rgba(24, 43, 34, 0.08); transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(53, 95, 75, 0.2); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { color: #fff; background: var(--green-dark); border-color: var(--green-dark); }
.button-quiet { background: transparent; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-danger:hover { color: #fff; background: #83332d; border-color: #83332d; }
.button-danger-quiet { color: var(--danger); background: transparent; border-color: #dfbbb8; }
.button-small { min-height: 36px; padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.button-block { width: 100%; }
.button[disabled] { opacity: .65; cursor: wait; transform: none; }
.button-group, .form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.flash-region { position: fixed; z-index: 200; top: 86px; right: 22px; width: min(420px, calc(100% - 44px)); }
.alert { padding: 13px 16px; margin-bottom: 12px; border: 1px solid; border-radius: 12px; background: #fff; box-shadow: var(--shadow); font-size: 14px; }
.alert-success { color: #225a3e; background: #edf8f1; border-color: #b9dfc8; }
.alert-error { color: #872f2a; background: #fff0ef; border-color: #ebc2bf; }
.alert-warning { color: #755521; background: #fff8e9; border-color: #ead8ad; }

.member-list { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.member-row { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row:hover { background: #fcfdfb; }
.member-avatar { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; color: #2d5140; background: var(--green-soft); font-family: Georgia, serif; font-size: 20px; font-weight: 700; }
.member-avatar.sex-f { color: #7a4754; background: #f3e2e6; }
.member-avatar.sex-u { color: #5d625f; background: #e7e9e7; }
.member-summary { min-width: 0; }
.member-summary h2 { display: flex; margin: 0 0 4px; align-items: center; gap: 8px; font-family: Georgia, serif; font-size: 20px; font-weight: 600; }
.member-summary h2 a { color: var(--ink); text-decoration: none; }
.new-badge { display: inline-flex; padding: 3px 6px; align-items: center; color: #fff; background: var(--gold); border-radius: 999px; font-family: Inter, ui-sans-serif, sans-serif; font-size: 8px; font-weight: 850; letter-spacing: .08em; line-height: 1; text-transform: uppercase; }
.member-meta, .member-relations { display: flex; gap: 0; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.member-meta span + span::before, .member-relations span + span::before { content: "·"; margin: 0 7px; color: #aeb6b1; }
.member-relations { margin-top: 4px; color: #4f5d55; }
.member-actions { display: flex; gap: 8px; }

.form-page { width: min(900px, calc(100% - 40px)); }
.member-form { display: grid; gap: 20px; }
.form-section, .detail-card, .confirmation-card { padding: clamp(24px, 4vw, 36px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-heading { display: grid; grid-template-columns: 1fr minmax(240px, 360px); gap: 30px; align-items: end; padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.section-heading p { font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.field { min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field label { display: block; margin: 0 0 7px; font-size: 13px; font-weight: 750; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd3cd;
  border-radius: 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field select[multiple] { min-height: 190px; padding: 7px; }
.field select[multiple] option { padding: 7px 8px; border-radius: 6px; }
.field textarea { resize: vertical; line-height: 1.55; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #aebbb3; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.field.has-error input, .field.has-error select { border-color: #cb6962; }
.field .field-error { color: var(--danger); }
.required-note { color: var(--danger); }
.form-footnote { margin: 20px 0 0; color: var(--muted); font-size: 12px; }
.sticky-actions { position: sticky; z-index: 20; bottom: 16px; width: fit-content; padding: 10px; background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }

.detail-heading { align-items: center; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.detail-card { min-height: 220px; }
.detail-list { margin: 16px 0 0; }
.detail-list > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-list > div:last-child { border: 0; }
.detail-list dt { color: var(--muted); font-size: 13px; }
.detail-list dd { margin: 0; font-weight: 650; }
.card-heading-inline { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.card-heading-inline a { font-size: 13px; font-weight: 700; }
.origin-list { margin-top: 15px; }
.origin-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.origin-row:last-child { border: 0; }
.biography { margin: 15px 0 0; }
.muted { color: var(--muted); }
.confirmation-card { margin-top: 30px; }
.confirmation-card p { color: var(--muted); }
.confirmation-card .form-actions { margin-top: 28px; }

.origin-editor { display: grid; grid-template-columns: minmax(0, 2fr) minmax(130px, 1fr); gap: 16px 20px; }
.input-suffix { display: flex; align-items: center; }
.input-suffix input { border-radius: 10px 0 0 10px; }
.input-suffix span { display: grid; height: 46px; padding: 0 14px; place-items: center; background: var(--soft); border: 1px solid #cbd3cd; border-left: 0; border-radius: 0 10px 10px 0; color: var(--muted); font-weight: 700; }

.empty-state { width: min(620px, calc(100% - 40px)); margin: 80px auto; padding: 50px 30px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state p { color: var(--muted); }

.login-page { display: grid; min-height: 100vh; place-items: center; background: radial-gradient(circle at 50% -10%, #e2ede5, transparent 45%), var(--paper); }
.login-shell { width: min(460px, calc(100% - 34px)); padding: 30px 0; }
.login-panel { padding: clamp(32px, 8vw, 50px); background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 26px 70px rgba(24, 43, 34, .12); }
.login-brand { width: 52px; height: 52px; margin-bottom: 26px; font-size: 25px; }
.login-panel h1 { margin-top: 7px; font-size: 38px; }
.login-panel > p { color: var(--muted); }
.login-panel form { display: grid; gap: 20px; margin-top: 30px; }
.privacy-note { margin: 24px 0 0; text-align: center; font-size: 11px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  :root { --header-height: 64px; }
  .site-header { padding: 0 18px; }
  .nav-toggle { display: inline-flex; padding: 7px 10px; color: var(--ink); background: var(--soft); border: 0; border-radius: 8px; font-weight: 700; }
  .site-nav { display: none; position: absolute; top: calc(100% + 8px); left: 12px; right: 12px; padding: 9px; align-items: stretch; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
  .site-nav.is-open { display: flex; }
  .logout-form { margin: 4px 0 0; padding: 4px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .logout-form button { width: 100%; }
  .page-shell, .page-wide, .form-page { width: min(100% - 28px, 960px); padding-top: 35px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .page-heading h1 { font-size: 38px; }
  .member-row { grid-template-columns: 42px minmax(0, 1fr); gap: 13px; padding: 17px; }
  .member-avatar { width: 42px; height: 42px; border-radius: 12px; }
  .member-actions { grid-column: 1 / -1; padding-left: 55px; }
  .form-grid, .detail-grid, .section-heading { grid-template-columns: 1fr; }
  .section-heading { gap: 10px; }
  .field.span-2 { grid-column: auto; }
  .form-section, .detail-card, .confirmation-card { padding: 22px; }
  .origin-editor { grid-template-columns: minmax(0, 2fr) minmax(100px, 1fr); }
  .detail-list > div { grid-template-columns: 90px minmax(0, 1fr); }
}
