/* ==========================================================================
   케어조아 공통 스타일 (모바일 우선)
   - 어르신·보호자 대상: 기본 글자 17px, 터치 영역 최소 48px, 고대비
   - 외부 CSS 프레임워크 없이 이 파일 하나로 모든 페이지를 구성합니다.
   ========================================================================== */

:root {
  --brand: #d9480f;          /* 버튼·강조 (흰 글자 대비 4.6:1) */
  --brand-strong: #b83b0a;
  --brand-soft: #fff4e6;
  --brand-line: #ffd8a8;
  --sun: #fab005;

  --ink: #1a1a1a;
  --ink-2: #495057;
  --ink-3: #6b7280;
  --line: #e9ecef;
  --bg: #f8f9fa;
  --card: #ffffff;

  --blue: #1c64d8;
  --blue-soft: #e7f0ff;
  --green: #2b8a3e;
  --green-soft: #ebfbee;
  --red: #c92a2a;
  --red-soft: #fff5f5;
  --yellow-soft: #fff9db;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);

  --header-h: 56px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  word-break: keep-all;
  overflow-wrap: anywhere;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.35; margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }
[hidden] { display: none !important; }

.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;
}

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* ---------- 헤더 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-t);
}
.app-header .inner {
  height: var(--header-h);
  max-width: 720px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none;
}
.logo .emoji { font-size: 24px; }
.header-call {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong);
  font-weight: 700; font-size: 15px; text-decoration: none;
}
.desktop-nav { display: none; }

/* ---------- 하단 탭바 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar ul {
  list-style: none; margin: 0 auto; padding: 0; max-width: 720px;
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabbar a {
  height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-3); font-size: 13px; font-weight: 600;
}
.tabbar a .ico { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar a[aria-current="page"] .ico { filter: none; opacity: 1; }

/* ---------- 레이아웃 ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 20px; padding-bottom: 32px; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 24px; }

.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { color: var(--ink-2); margin-top: 6px; font-size: 16px; }
.section-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.eyebrow {
  display: inline-block; font-size: 13px; font-weight: 700; color: var(--brand-strong);
  background: var(--brand-soft); padding: 4px 10px; border-radius: 999px;
}
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 카드 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-flat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2, .card h3 { margin-bottom: 8px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 22px; border-radius: 14px; border: 0;
  font-size: 18px; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background-color .15s ease, opacity .15s;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
.btn-primary:disabled { background: #ced4da; color: #fff; cursor: not-allowed; transform: none; }
.btn-secondary { background: #fff; color: var(--ink); border: 1.5px solid #ced4da; }
.btn-soft { background: var(--brand-soft); color: var(--brand-strong); }
.btn-ghost { background: transparent; color: var(--ink-2); min-height: 48px; font-size: 16px; }
.btn-sm { min-height: 44px; font-size: 16px; padding: 0 16px; border-radius: 12px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 선택 칩 (라디오/체크) ---------- */
.choice-group { display: grid; gap: 10px; }
.choice-group.cols-2 { grid-template-columns: 1fr 1fr; }
.choice-group.cols-3 { grid-template-columns: repeat(3, 1fr); }

.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice .box {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 12px 16px;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.choice .box .ico { font-size: 26px; line-height: 1; flex: none; }
.choice .box .txt { display: flex; flex-direction: column; min-width: 0; }
.choice .box .t { font-weight: 700; font-size: 17px; }
.choice .box .d { font-size: 14px; color: var(--ink-3); line-height: 1.4; }
.choice .box .check {
  margin-left: auto; flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #ced4da; display: grid; place-items: center;
}
.choice input:checked + .box { border-color: var(--brand); background: var(--brand-soft); }
.choice input:checked + .box .check { border-color: var(--brand); background: var(--brand); }
.choice input:checked + .box .check::after {
  content: ""; width: 10px; height: 6px; border: solid #fff; border-width: 0 0 2.5px 2.5px;
  transform: translateY(-1px) rotate(-45deg);
}
.choice input:focus-visible + .box { outline: 3px solid var(--blue); outline-offset: 2px; }

/* 세로형(아이콘 위) 칩: 등급 선택 등 */
.choice.tile .box { flex-direction: column; justify-content: center; text-align: center; gap: 2px; min-height: 76px; padding: 10px 6px; }
.choice.tile .box .t { font-size: 18px; }
.choice.tile .box .d { font-size: 13px; }
.choice.tile .box .check { display: none; }

/* ---------- 폼 ---------- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 16px; }
.label .req { color: var(--red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; min-height: 54px; padding: 12px 14px;
  border: 1.5px solid #ced4da; border-radius: 12px; background: #fff; font-size: 17px;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(217,72,15,.15); }
.hint { font-size: 14px; color: var(--ink-3); margin-top: 6px; }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--ink-2); }
.checkline input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); flex: none; }

/* ---------- 스텝(질문 블록) ---------- */
.q-block { scroll-margin-top: calc(var(--header-h) + 16px); }
.q-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.q-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 800;
  display: grid; place-items: center; transform: translateY(3px);
}
.q-title { font-size: 20px; font-weight: 800; }
.q-block.is-locked { opacity: .45; pointer-events: none; }

/* ---------- 결과 요약 ---------- */
.result-hero {
  background: linear-gradient(160deg, #fff4e6 0%, #ffffff 70%);
  border: 2px solid var(--brand-line);
  border-radius: 20px; padding: 22px 20px;
}
.result-hero .label-sm { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.result-hero .big {
  font-size: 40px; font-weight: 800; letter-spacing: -0.03em; color: var(--brand-strong);
  line-height: 1.15; margin-top: 4px;
}
.result-hero .big small { font-size: 20px; font-weight: 700; margin-left: 2px; }
.result-hero .range { font-size: 15px; color: var(--ink-2); margin-top: 4px; }

.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-2); font-size: 16px; }
.kv .v { font-weight: 700; font-size: 17px; text-align: right; white-space: nowrap; }
.kv.total .k { color: var(--ink); font-weight: 800; }
.kv.total .v { color: var(--brand-strong); font-size: 20px; font-weight: 800; }
.kv .v.plus { color: var(--green); }

.bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .gov { background: #4dabf7; }
.bar .self { background: var(--brand); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* ---------- 알림 박스 ---------- */
.note { border-radius: var(--radius-sm); padding: 14px 16px; font-size: 15px; line-height: 1.6; }
.note strong { font-weight: 700; }
.note-info { background: var(--blue-soft); color: #0b3d91; }
.note-warn { background: var(--yellow-soft); color: #6b4e00; }
.note-ok { background: var(--green-soft); color: #1e5e2b; }
.note-danger { background: var(--red-soft); color: #8a1c1c; }
.note-title { font-weight: 800; margin-bottom: 4px; display: block; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; background: #fff; }
.tbl th, .tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { background: #f1f3f5; font-weight: 700; color: var(--ink-2); font-size: 14px; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .hl td { background: var(--brand-soft); font-weight: 700; }

/* ---------- 아코디언 ---------- */
details.acc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); }
details.acc + details.acc { margin-top: 10px; }
details.acc > summary {
  list-style: none; cursor: pointer; padding: 16px; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 700; font-size: 17px;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after {
  content: ""; flex: none; width: 10px; height: 10px;
  border: solid var(--ink-3); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-3px);
  transition: transform .2s;
}
details.acc[open] > summary::after { transform: rotate(-135deg) translateY(-3px); }
details.acc > .acc-body { padding: 0 16px 16px; color: var(--ink-2); font-size: 16px; }
details.acc > .acc-body > * + * { margin-top: 10px; }

/* ---------- 리스트 ---------- */
.list-check { list-style: none; padding: 0; }
.list-check li { position: relative; padding-left: 28px; }
.list-check li + li { margin-top: 8px; }
.list-check li::before { content: "✓"; position: absolute; left: 4px; top: 0; color: var(--green); font-weight: 800; }

.steps { list-style: none; padding: 0; counter-reset: s; }
.steps li { position: relative; padding: 0 0 18px 44px; counter-increment: s; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff;
  font-weight: 800; font-size: 15px; display: grid; place-items: center;
}
.steps li::after { content: ""; position: absolute; left: 14px; top: 34px; bottom: 4px; width: 2px; background: var(--brand-line); }
.steps li:last-child { padding-bottom: 0; }
.steps li:last-child::after { display: none; }
.steps .st { font-weight: 800; display: block; }
.steps .sd { color: var(--ink-2); font-size: 15px; }

/* ---------- 링크 카드 ---------- */
.link-card {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-decoration: none; color: var(--ink); min-height: 72px;
}
.link-card .ico { font-size: 30px; flex: none; }
.link-card .t { font-weight: 800; font-size: 17px; display: block; }
.link-card .d { font-size: 14px; color: var(--ink-3); display: block; }
.link-card::after {
  content: ""; margin-left: auto; flex: none; width: 9px; height: 9px;
  border: solid #adb5bd; border-width: 2px 2px 0 0; transform: rotate(45deg);
}
.link-card.promo { background: linear-gradient(135deg, #fff4e6, #ffe8cc); border-color: var(--brand-line); }

/* ---------- 진행바 ---------- */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); width: 0; transition: width .25s ease; }

/* ---------- 하단 고정 액션바 ---------- */
.sticky-cta {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 40; margin: 0 -16px; padding: 12px 16px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(248,249,250,0));
}

/* ---------- 푸터 ---------- */
.app-footer { background: #fff; border-top: 1px solid var(--line); padding: 28px 0 24px; margin-top: 24px; font-size: 13px; color: var(--ink-3); line-height: 1.7; }
.app-footer .links { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.app-footer .links a { color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14px; min-height: 32px; display: inline-flex; align-items: center; }
.app-footer .biz { margin-top: 8px; }
.app-footer .disclaimer { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 10px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #212529; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 애니메이션 (움직임 줄이기 존중) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: reveal .35s ease both; }
  @keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ---------- 작은 화면 ---------- */
@media (max-width: 360px) {
  body { font-size: 16px; }
  .choice-group.cols-3 { grid-template-columns: 1fr 1fr; }
  .result-hero .big { font-size: 34px; }
  .page-title { font-size: 23px; }
}

/* ---------- 태블릿/데스크탑 ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .desktop-nav { display: flex; gap: 4px; }
  .desktop-nav a {
    text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 16px;
    padding: 8px 12px; border-radius: 10px;
  }
  .desktop-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
  .sticky-cta { bottom: 0; }
  .toast { bottom: 24px; }
  .page { padding-top: 32px; }
  .page-title { font-size: 32px; }
}

@media print {
  .app-header, .tabbar, .sticky-cta, .no-print { display: none !important; }
  body { padding: 0; background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
