/*
 * 발담 디자인 토큰과 컴포넌트.
 *
 * 토큰 값은 Baldam v3.dc.html의 :root 블록에서 그대로 가져왔다.
 * 캔버스와 앱이 갈라지지 않도록 여기서만 바꾸고, 색·간격·서체를 하드코딩하지 않는다.
 *
 * (_ds/의 Industry 디자인 시스템은 캔버스가 덮어쓴 것이라 따르지 않는다. CLAUDE.md 참고.)
 */

:root {
  --color-bg: #fbf8f0;
  --color-text: #2e3a33;
  --color-divider: #e6e0d2;
  --color-accent: #5f9b6f;
  --color-accent-100: #eef6ef;
  --color-accent-200: #dceadd;
  --color-accent-300: #bfd9c4;
  --color-accent-400: #8fbf9b;
  --color-accent-600: #4d8a5e;
  --color-accent-700: #3d7350;
  --color-accent-800: #2f5b40;
  --color-neutral-100: #fdfbf6;
  --color-neutral-200: #f4efe3;
  --color-neutral-300: #e9e2d2;
  --color-neutral-400: #d6cdb9;
  --color-neutral-700: #7c7565;
  --color-neutral-800: #5c5648;
  --color-neutral-900: #3b372e;

  --radius: 16px; --radius-sm: 10px; --radius-md: 16px; --radius-lg: 24px;

  --sky: #74a9d8; --sky-deep: #3d78ac; --sky-soft: #e8f1f9;
  --sun: #d9a441; --sun-deep: #96691a; --sun-soft: #faf1dd;
  --clay: #b8705f; --clay-deep: #8b4b3c; --clay-soft: #f8ebe7;
  --earth: #9a7a5c; --earth-soft: #f3ece2;

  --shadow-soft: 0 1px 2px rgba(46,58,51,.04), 0 8px 24px -12px rgba(46,58,51,.14);
  --shadow-lift: 0 2px 6px rgba(46,58,51,.06), 0 18px 40px -18px rgba(46,58,51,.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% 0%, var(--sky-soft) 0%, rgba(232,241,249,0) 62%),
    linear-gradient(var(--color-bg), var(--color-bg));
  font-family: "IBM Plex Sans KR", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Nunito", "IBM Plex Sans KR", sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.28;
  text-wrap: pretty;
}
p { text-wrap: pretty; }
input, button, select, textarea { font-family: inherit; }
button { cursor: pointer; transition: transform .12s cubic-bezier(.2,.7,.3,1), box-shadow .2s, background .2s, border-color .2s, color .2s; }
button:active { transform: scale(.975); }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

/* ── 셸 ─────────────────────────────────────────────────── */

.shell {
  display: flex; flex-direction: column; min-height: 100vh;
  /* 어딘가에서 폭이 새더라도 페이지 전체가 좌우로 밀리지는 않게 한다.
     body가 아니라 여기에 거는 이유는 body에 걸면 sticky 헤더가 깨지기 때문이다. */
  overflow-x: clip;
}

.header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(251,248,240,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
}
.header-inner {
  max-width: 1240px; margin: 0 auto;
  padding: 12px clamp(16px, 4vw, 36px) 0;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  background: none; border: 0; padding: 0; margin-right: auto;
  display: flex; align-items: center; gap: 9px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(160deg, var(--sky) 0%, var(--color-accent) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px;
}
.brand-text { display: grid; grid-template-columns: minmax(0, 1fr); text-align: left; line-height: 1.15; }
.brand-name { font-family: "Nunito", sans-serif; font-weight: 800; font-size: 19px; color: var(--color-accent-800); }
.brand-sub { font-size: 10.5px; color: var(--color-neutral-700); }

.tabs {
  max-width: 1240px; margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 36px) 12px;
  display: flex; gap: 7px; overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; white-space: nowrap;
  border: 1px solid var(--color-divider); background: #fff;
  color: var(--color-neutral-800);
  border-radius: 999px; padding: 8px 15px;
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { border-color: var(--color-accent-300); }
.tab[aria-current="page"] {
  background: var(--color-accent); border-color: var(--color-accent);
  color: #fff; font-weight: 600; box-shadow: var(--shadow-soft);
}
.tab-count {
  background: var(--color-accent-100); color: var(--color-accent-800);
  border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.tab[aria-current="page"] .tab-count { background: rgba(255,255,255,.24); color: #fff; }

.main {
  flex: 1; width: 100%; max-width: 1240px; margin: 0 auto;
  padding: clamp(22px, 4vw, 40px) clamp(16px, 4vw, 36px) 72px;
}

/* ── 공통 조각 ──────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--color-accent-100); color: var(--color-accent-800);
  border-radius: 999px; padding: 5px 13px;
  font-size: 12px; font-weight: 500;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 26px;
}
.page-head h1 { font-size: clamp(27px, 5.2vw, 40px); margin: 14px 0 12px; }
.page-head p { font-size: 15px; line-height: 1.75; color: var(--color-neutral-800); margin: 0; max-width: 620px; }

.btn-primary {
  border: 0; background: var(--color-accent); color: #fff;
  border-radius: 999px; padding: 15px 27px;
  font-size: 15px; font-weight: 700; box-shadow: var(--shadow-lift);
}
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-dashed {
  border: 1px dashed var(--color-accent-400); background: #fff;
  color: var(--color-accent-800); border-radius: var(--radius-md);
  padding: 13px 20px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-soft);
}
.btn-dashed:hover { border-color: var(--color-accent); background: var(--color-accent-100); }

.btn-quiet {
  background: none; border: 0; padding: 2px 0;
  font-size: 12.5px; color: var(--color-neutral-700);
  text-decoration: underline; text-underline-offset: 3px;
  justify-self: start;
}
.btn-quiet:hover { color: var(--clay-deep); }

.input {
  background: #fff; border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 14.5px; color: var(--color-text); width: 100%;
}
.input::placeholder { color: var(--color-neutral-400); }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; }
.field-label { font-size: 11.5px; color: var(--color-neutral-700); }

/* ── 우리 아이 카드 ─────────────────────────────────────── */

.dog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(288px, 100%), 1fr)); gap: 18px; }

.dog-card {
  background: #fff; border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-soft);
  padding: 18px; transition: box-shadow .22s, border-color .22s, opacity .22s;
}
.dog-card[data-active="true"] { border-color: var(--color-accent-300); box-shadow: var(--shadow-lift); }
.dog-card[data-active="false"] { opacity: .62; }

.dog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.dog-avatar {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%;
  background: var(--color-accent-100);
  display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.dog-id { flex: 1; min-width: 0; }
.dog-name { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dog-sub { font-size: 12.5px; color: var(--color-neutral-700); }

.toggle {
  flex: 0 0 auto; border-radius: 999px; padding: 6px 13px;
  font-size: 12px; font-weight: 600; border: 1px solid;
}
.toggle[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.toggle[aria-pressed="false"] { background: #fff; border-color: var(--color-divider); color: var(--color-neutral-700); }

.dog-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.dog-row2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--color-divider); background: #fff; color: var(--color-neutral-800);
  /* 줄어들지 않고 한 줄을 유지한다. 없으면 글자가 세로로 쪼개지고 행이 뷰포트를 넘긴다. */
  flex: 0 0 auto; white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--sun-soft); border-color: var(--sun); color: var(--sun-deep); font-weight: 600;
}
.chip[aria-pressed="true"][data-tone="risk"] {
  background: var(--clay-soft); border-color: var(--clay); color: var(--clay-deep);
}

/* ── 요약 바 ────────────────────────────────────────────── */

.summary {
  margin-top: 24px; border-radius: var(--radius-lg);
  background: linear-gradient(140deg, #fff 0%, var(--color-accent-100) 100%);
  border: 1px solid var(--color-accent-200); box-shadow: var(--shadow-soft);
  padding: clamp(20px, 3vw, 28px);
  display: flex; gap: 26px; flex-wrap: wrap; align-items: center;
}
.stat { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; min-width: 116px; }
.stat-label { font-size: 11.5px; color: var(--color-accent-800); }
.stat-value { font-family: "Nunito", sans-serif; font-weight: 800; font-size: 25px; line-height: 1.1; }
.summary .btn-primary { margin-left: auto; }

/* ── 빈 상태 ────────────────────────────────────────────── */

.empty {
  background: #fff; border: 1px dashed var(--color-neutral-400);
  border-radius: var(--radius-lg); padding: clamp(28px, 5vw, 48px);
  text-align: center; color: var(--color-neutral-800);
}
.empty h2 { margin: 0 0 8px; font-size: 19px; }
.empty p { margin: 0 0 20px; font-size: 14px; line-height: 1.7; }

.notice {
  background: var(--sun-soft); border: 1px solid var(--sun);
  color: var(--sun-deep); border-radius: var(--radius-md);
  padding: 12px 16px; font-size: 13.5px; line-height: 1.6;
}

@media (max-width: 480px) {
  .dog-row2 { grid-template-columns: 1fr; }
  .summary .btn-primary { margin-left: 0; width: 100%; }
}

/* ── 탐색 · 판정 ────────────────────────────────────────── */

.scrollx { overflow-x: auto; scrollbar-width: none; }
.scrollx::-webkit-scrollbar { display: none; }

.filters {
  background: #fff; border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-soft);
  padding: 16px 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 13px; margin-bottom: 22px;
}
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.filter-row .chips { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; }
/* .input의 width:100%를 그대로 두면 flex 행 안에서 컨테이너 폭 전체를 요구해
   옆의 칩 목록과 합쳐져 행이 뷰포트를 넘긴다. 필터 안에서는 내용만큼만 차지한다. */
.filter-row .input { width: auto; flex: 0 0 auto; max-width: 100%; }
.filter-row-sub { border-top: 1px solid var(--color-divider); padding-top: 13px; flex-wrap: wrap; }
.filter-hint { font-size: 12.5px; color: var(--color-neutral-700); }
.chip:disabled { opacity: .45; cursor: not-allowed; }

.split { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.list {
  flex: 1 1 320px; min-width: 0; display: grid; gap: 13px;
  /* 트랙을 명시하지 않으면 암시적 auto 트랙이 max-content로 커져 컨테이너를 넘긴다.
     그러면 카드 안의 text-overflow:ellipsis가 영영 동작하지 않는다 —
     줄일 필요가 없다고 판단해 버리기 때문이다. minmax(0,1fr)로 상한을 못 박는다. */
  grid-template-columns: minmax(0, 1fr);
}
.detail-wrap { flex: 1.3 1 380px; min-width: 0; position: sticky; top: 108px; }

.row {
  background: #fff; border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-soft);
  padding: 13px; display: flex; gap: 14px; cursor: pointer;
  transition: box-shadow .2s, border-color .2s;
}
.row:hover { border-color: var(--color-accent-300); box-shadow: var(--shadow-lift); }
.row[data-selected="true"] { border-color: var(--color-accent); box-shadow: var(--shadow-lift); }

.row-thumb {
  width: 84px; height: 84px; flex: 0 0 auto; border-radius: var(--radius-md);
  background: var(--color-neutral-200) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.row-body { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.row-name { font-size: 17px; margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-addr { font-size: 12.5px; color: var(--color-neutral-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-tags { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.row-conf { margin-left: auto; font-size: 11px; color: var(--color-neutral-700); }
.row-conf[data-level="NONE"], .row-conf[data-level="LOW"] { color: var(--clay-deep); }

.minitag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--color-neutral-200); color: var(--color-neutral-800);
}

/* 신호등 */
.verdict {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 4px 11px;
  font-size: 12px; font-weight: 700; border: 1px solid;
}
.verdict-glyph { font-size: 11px; }
.verdict[data-tone="ok"]   { background: var(--color-accent-100); border-color: var(--color-accent-300); color: var(--color-accent-800); }
.verdict[data-tone="warn"] { background: var(--sun-soft); border-color: var(--sun); color: var(--sun-deep); }
.verdict[data-tone="no"]   { background: var(--clay-soft); border-color: var(--clay); color: var(--clay-deep); }
.verdict[data-tone="none"] { background: var(--color-neutral-200); border-color: var(--color-divider); color: var(--color-neutral-700); }
.verdict-lg { font-size: 13px; padding: 6px 14px; }

/* 신뢰도 */
.conf { margin: 18px 0; }
.conf-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.conf-label { font-size: 12px; color: var(--color-neutral-700); }
.conf-value { font-size: 12.5px; font-weight: 700; color: var(--color-accent-800); }
.conf-value[data-level="LOW"], .conf-value[data-level="NONE"] { color: var(--clay-deep); }
.conf-bar { display: flex; gap: 4px; }
.conf-seg { height: 6px; flex: 1; border-radius: 999px; background: var(--color-neutral-300); }
.conf-seg[data-on="true"] { background: var(--color-accent); }
.conf-seg[data-on="true"][data-level="LOW"],
.conf-seg[data-on="true"][data-level="NONE"] { background: var(--clay); }

/* 상세 패널 */
.detail {
  background: #fff; border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lift); overflow: hidden;
}
.detail-empty {
  padding: 44px 24px; text-align: center; color: var(--color-neutral-700);
  font-size: 14px; box-shadow: var(--shadow-soft);
}
.detail-hero {
  position: relative; min-height: 168px;
  background: var(--color-accent-200) center/cover no-repeat;
  display: flex; align-items: flex-end;
}
.detail-hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(30,42,34,.55) 0%, rgba(30,42,34,0) 60%);
}
.detail-title {
  position: relative; margin: 0; padding: 18px;
  font-size: clamp(21px, 3.2vw, 28px); color: #fff;
  overflow-wrap: anywhere;
}
.detail-body { padding: clamp(18px, 3vw, 28px); }
.detail-headline {
  font-size: clamp(20px, 3vw, 27px); line-height: 1.3; margin: 12px 0 4px;
  overflow-wrap: anywhere;
}
.detail-h4 {
  font-size: 12px; font-weight: 700; color: var(--color-neutral-700);
  margin: 22px 0 9px; letter-spacing: .04em;
}

.reasons { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.reason {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 13.5px; line-height: 1.6;
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.reason[data-level="BLOCK"] { background: var(--clay-soft); color: var(--clay-deep); }
.reason[data-level="CAUTION"] { background: var(--sun-soft); color: var(--sun-deep); }
.reason-glyph { flex: 0 0 auto; font-size: 11px; line-height: 1.9; }

.cond {
  margin: 0; display: grid; grid-template-columns: auto 1fr;
  gap: 7px 14px; font-size: 13.5px;
}
.cond dt { color: var(--color-neutral-700); font-size: 12.5px; }
.cond dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.raw { margin-top: 20px; font-size: 13px; }
.raw summary { cursor: pointer; color: var(--color-accent-700); }
.raw pre {
  margin: 10px 0 0; padding: 12px 14px; white-space: pre-wrap; word-break: break-word;
  background: var(--color-neutral-100); border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.7;
  color: var(--color-neutral-800); font-family: inherit;
}

.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 22px; }
.action {
  text-decoration: none; border: 1px solid var(--color-accent-300);
  background: #fff; color: var(--color-accent-800);
  border-radius: 999px; padding: 10px 18px; font-size: 13.5px; font-weight: 600;
}
.action:hover { background: var(--color-accent-100); }

.source { margin: 20px 0 0; font-size: 11.5px; color: var(--color-neutral-700); }

@media (max-width: 900px) {
  .detail-wrap { position: static; }
}

/* ── 로딩: 발바닥에 색이 차오른다 ───────────────────────── */

.loader {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(251, 248, 240, .72);
  backdrop-filter: blur(3px);
  /* 클릭을 막지 않는다. 로딩이 길어져도 사용자가 갇히지 않게 한다. */
  pointer-events: none;
  animation: loader-in .18s ease-out both;
}
.loader[hidden] { display: none !important; }

@keyframes loader-in { from { opacity: 0; } to { opacity: 1; } }

.loader-box {
  display: grid; grid-template-columns: minmax(0, 1fr);
  justify-items: center; gap: 14px;
  max-width: min(280px, 80vw); text-align: center;
}

.paw { width: 76px; height: 76px; display: block; }
.paw-base { fill: var(--color-accent-200); }
.paw-fill { fill: var(--color-accent); }

.loader-label {
  margin: 0; font-size: 13px; font-weight: 500;
  color: var(--color-accent-800);
}

@media (prefers-reduced-motion: reduce) {
  .loader { animation: none; }
  /* 채우기 애니메이션은 loading.js가 아예 걸지 않는다. 발바닥이 채워진 채로 은은하게 숨쉰다. */
  .paw { animation: paw-breathe 1.6s ease-in-out infinite; }
}
@keyframes paw-breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* 좁은 화면에서는 상세를 고른 카드 바로 아래에 끼워 넣는다.
   오른쪽 칸이 목록 아래로 내려가면 고른 곳을 보려고 목록 전체를 지나쳐야 한다. */
.detail-inline { margin: 2px 0 6px; }
.detail-inline .detail { box-shadow: var(--shadow-lift); }

/* 고른 장소가 바뀔 때만 재생된다. explore.js가 클래스를 붙일지 판단한다. */
.detail-enter { animation: detail-enter .26s cubic-bezier(.2, .7, .3, 1) both; }

@keyframes detail-enter {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .detail-enter { animation: none; }
}
