:root {
  --green: #2f5d50;
  --green-soft: #e7efe9;
  --ink: #1f2522;
  --muted: #6b736f;
  --line: #dde3df;
  --bg: #f6f7f5;
  --danger: #b3261e;
  font-size: 18px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  line-height: 1.5; padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 12px 14px 24px; }
h1, h2 { line-height: 1.3; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

header#top {
  position: sticky; top: 0; z-index: 5; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
header#top h1 { font-size: 1.1rem; margin: 0; }
header#top .link { color: #fff; }

button, .btn {
  font: inherit; min-height: 48px; border-radius: 12px; padding: 0 18px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button.primary { background: var(--green); color: #fff; border-color: var(--green); width: 100%; margin: 12px 0 6px; font-weight: 700; }
button.secondary { width: 100%; margin: 6px 0; }
button.link { background: none; border: 0; min-height: 44px; padding: 0 6px; color: var(--green); text-decoration: underline; }
button.link.danger { color: var(--danger); }
button:disabled { opacity: .6; }

.signin { text-align: center; padding-top: 12vh; }
.signin .logo { width: 96px; height: 96px; border-radius: 22px; }
.signin h1 { font-size: 1.6rem; }
.panel { background: #fff; border-radius: 16px; padding: 24px 18px; margin-top: 8vh; border: 1px solid var(--line); }

.toolbar { position: sticky; top: 58px; z-index: 4; background: var(--bg); padding: 6px 0 8px; }
input[type=search], input[type=text], input[type=tel], select {
  font: inherit; width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-top: 8px; scrollbar-width: none; }
.chip { min-height: 40px; border-radius: 20px; white-space: nowrap; padding: 0 14px; font-size: .9rem; }
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }
.count { margin: 4px 2px; }

.cards { display: grid; gap: 10px; }
.card {
  display: flex; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  transition: box-shadow .3s;
}
.card.flash { box-shadow: 0 0 0 3px var(--green); }
.photo { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; flex: none; background: var(--green-soft); }
.photo.initial { display: flex; align-items: center; justify-content: center; color: var(--green); font-weight: 700; font-size: 1.2rem; }
.card .body { min-width: 0; flex: 1; }
.card h2 { font-size: 1.15rem; margin: 2px 0 4px; }
.card .title { font-weight: 400; color: var(--muted); font-size: 1rem; }
.badge { display: inline-block; margin-left: 6px; font-size: .75rem; font-weight: 400; background: #eee; color: #555; border-radius: 8px; padding: 1px 8px; vertical-align: middle; }
.card p { margin: 4px 0; }
.family { color: #3d4541; }
.family a { color: var(--green); }
.phone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.phone span { font-variant-numeric: tabular-nums; flex-basis: 100%; font-size: 1.05rem; }
.phone .btn { min-height: 40px; padding: 0 14px; font-size: .9rem; background: var(--green-soft); border-color: transparent; color: var(--green); font-weight: 700; }
.meta { color: var(--muted); font-size: .95rem; }

nav#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav#tabs button { flex: 1; border: 0; border-radius: 0; min-height: 60px; background: #fff; color: var(--muted); }
nav#tabs button.active { color: var(--green); font-weight: 700; }

.apply h2, .section-title { margin: 8px 0 4px; }
fieldset.person { border: 1px solid var(--line); border-radius: 16px; background: #fff; margin: 12px 0; padding: 8px 14px 14px; }
fieldset.person legend { font-weight: 700; padding: 0 6px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row select { flex: 1; min-width: 0; }
.preview { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: var(--green-soft); display: flex; align-items: center; justify-content: center; flex: none; text-align: center; }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.check input { width: 24px; height: 24px; margin-top: 2px; flex: none; accent-color: var(--green); }
.consent { background: var(--green-soft); border-radius: 16px; padding: 4px 14px; margin-top: 14px; }
.error { color: var(--danger); font-weight: 600; min-height: 1em; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 10; max-width: 90vw; }

.lock { margin-left: 8px; font-size: .75rem; color: #8a5a00; background: #fff4dc; border-radius: 8px; padding: 1px 8px; vertical-align: middle; white-space: nowrap; }
