/*
 * 교인 주소록 · 브라우저 화면.
 *
 * 색은 모바일 앱(DAC_app src/theme/colors.ts) 및 관리자 화면과 동일하게 맞춘다.
 * 교인이 앱에서 보든 브라우저에서 보든 같은 물건으로 느껴져야 한다.
 */

:root {
  --navy:  #1E3A5F;
  --navy2: #3B5A8C;
  --gold:  #D4A857;
  --bg:    #F7F8FA;
  --card:  #FFFFFF;
  --line:  #CFD4DC;
  --text:  #1F2937;
  --muted: #6B7280;
  --err:   #DC2626;
  --r:     12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------------------------------------------------- 인증 */

.auth {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--navy) 0%, #16293f 100%);
}
.auth-card {
  background: var(--card);
  border-radius: 18px;
  padding: 34px 28px 26px;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
}
/* DAC_app 의 앱 아이콘을 그대로 쓴다. 교인이 휴대폰에서 보는 모양과
   같아야 같은 물건으로 인식된다. 원본은 모서리가 각져 있으므로
   (iOS 가 알아서 깎는다) 여기서 둥글게 처리한다. */
.auth-logo {
  width: 76px; height: 76px;
  margin: 0 auto 14px; display: block;
  border-radius: 18px;
  box-shadow: 0 3px 10px rgba(16, 24, 40, .18);
}
.auth-card h1 { font-size: 21px; margin: 0 0 2px; letter-spacing: -.02em; }
.auth-sub  { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.auth-help { margin: 0 0 14px; font-size: 14px; }
.auth-error {
  background: #FEF3F2; color: var(--err);
  border-radius: 8px; padding: 10px 12px; margin: 0 0 14px;
  font-size: 13.5px; text-align: left;
}
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#code {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; text-align: center;
  font-size: 22px; font-weight: 600; letter-spacing: .16em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}
#code:focus { outline: none; border-color: var(--navy2); box-shadow: 0 0 0 3px rgba(59,90,140,.16); }
#auth-form button {
  background: var(--navy); color: #fff; border: 0;
  border-radius: 10px; padding: 14px; font-size: 16px; font-weight: 600;
}
#auth-form button:disabled { opacity: .6; }
.auth-note { margin: 16px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------------------------------------------------------- 상단 */

.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  padding: max(10px, env(safe-area-inset-top)) 16px 12px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand-sub  { font-size: 11.5px; color: rgba(255,255,255,.6); }
.linkish {
  background: none; border: 0; color: rgba(255,255,255,.8);
  font-size: 13px; padding: 6px 2px; text-decoration: underline;
}
.search { display: flex; gap: 8px; margin-top: 12px; }
.search input, .search select {
  border: 0; border-radius: 10px; padding: 11px 13px;
  background: rgba(255,255,255,.13); color: #fff; font-size: 15px;
}
.search input { flex: 1 1 auto; min-width: 0; }
.search input::placeholder { color: rgba(255,255,255,.55); }
.search input:focus, .search select:focus {
  outline: none; background: rgba(255,255,255,.2);
}
.search select { flex: 0 0 auto; max-width: 42%; }
.search select option { color: var(--text); }
.meta { margin-top: 9px; font-size: 12px; color: rgba(255,255,255,.65); }
.offline { color: var(--gold); }

/* ---------------------------------------------------------- 목록 */

.list { padding: 8px 12px 90px; }
.bucket { scroll-margin-top: 150px; }
.bucket-h {
  font-size: 12px; font-weight: 700; color: var(--navy);
  padding: 14px 6px 6px; letter-spacing: .04em;
}
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 15px; margin-bottom: 7px;
}
.row:active { background: #EEF1F5; }
.row-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.row-name { font-size: 16px; font-weight: 600; }
.row-pos  { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row-sub  {
  font-size: 13px; color: var(--navy2); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty, .loading {
  padding: 60px 24px; text-align: center; color: var(--muted); font-size: 15px;
}

/* 가나다 이동 */
.index {
  position: fixed; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 1px; z-index: 15;
}
.index button {
  background: none; border: 0; color: var(--navy2);
  font-size: 11px; font-weight: 700; padding: 2px 6px; line-height: 1.3;
}
.index button:active { color: var(--gold); }

/* ---------------------------------------------------------- 상세 */

.detail-top { padding-bottom: 10px; }
.back { background: none; border: 0; color: #fff; font-size: 15px; padding: 4px 0; }
.detail { padding: 18px 16px 70px; }
.detail h1 { font-size: 25px; margin: 0 0 2px; letter-spacing: -.02em; }
.detail-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.acts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.act {
  display: flex; align-items: baseline; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; text-decoration: none; color: var(--navy2); font-size: 15px;
}
.act b { color: var(--text); font-size: 13px; min-width: 44px; }
.act:active { background: #EEF1F5; }

.kvs {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; margin-bottom: 22px;
}
.kv {
  display: flex; gap: 14px; padding: 11px 15px;
  border-bottom: 1px solid #EDF0F4; font-size: 14.5px;
}
.kv:last-child { border-bottom: 0; }
.kv span { flex: 0 0 88px; color: var(--muted); font-size: 13px; }
.kv b { font-weight: 500; word-break: break-word; }
.kv b.muted { color: var(--muted); font-weight: 400; }

.detail h3 {
  font-size: 13px; color: var(--navy); margin: 0 0 9px;
  display: flex; align-items: baseline; gap: 8px;
}
.hh-name { color: var(--muted); font-weight: 400; font-size: 12px; }
.family { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font-size: 14px;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.chip span { font-size: 11.5px; color: var(--muted); }
.chip:active { background: #EEF1F5; }

/* ---------------------------------------------------------- 넓은 화면 */

@media (min-width: 760px) {
  .top { padding: 14px 28px; }
  .list { max-width: 900px; margin: 0 auto; padding: 12px 28px 80px;
          display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
  .bucket { break-inside: avoid; }
  .bucket-h { grid-column: 1 / -1; }
  .detail { max-width: 640px; margin: 0 auto; }
  .search { max-width: 900px; }
  .index { right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* 교역자·사무실 진입구 — 코드 입력칸 아래 */
.auth-staff {
  margin-top: 18px; padding-top: 15px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px;
}
.auth-staff a {
  color: var(--navy2); text-decoration: none;
  font-size: 14px; font-weight: 600;
}
.auth-staff a:hover { text-decoration: underline; }
.auth-staff span { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------- 모달 */

.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 20, 34, .58);
  backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--card); border-radius: 16px;
  padding: 26px 24px 20px; width: 100%; max-width: 360px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .32);
}
.modal-x {
  position: absolute; top: 10px; right: 12px;
  background: none; border: 0; font-size: 24px; line-height: 1;
  color: var(--muted); padding: 4px 8px;
}
.modal-card h2 { font-size: 18px; margin: 0 0 2px; letter-spacing: -.02em; }
.modal-sub { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }

#staff-form { display: flex; flex-direction: column; gap: 12px; }
#staff-form label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px; color: var(--muted); text-align: left;
}
#staff-form input:not([type=checkbox]) {
  border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 12px; font-size: 15px; color: var(--text);
}
#staff-form input:focus {
  outline: none; border-color: var(--navy2);
  box-shadow: 0 0 0 3px rgba(59, 90, 140, .14);
}
#staff-form label.cbx {
  flex-direction: row; align-items: center; gap: 7px;
  color: var(--text); font-size: 13.5px;
}
#staff-form button {
  background: var(--navy); color: #fff; border: 0;
  border-radius: 9px; padding: 12px; font-size: 15px; font-weight: 600;
  margin-top: 2px;
}
#staff-form button:disabled { opacity: .6; }
.modal-note { margin: 14px 0 0; text-align: center; font-size: 12px; }
.modal-note a { color: var(--muted); }
