/* 루보 시연판 — 고객 프로토타입 토큰 기준 (.impeccable.md) */
:root {
  /* 색: 프로토타입 */
  --bg: #e9f0ef;
  --surface: #ffffff;
  --surface-soft: #f2f7f6;
  --ink: #172321;
  --muted: #64726f;
  --line: #dce6e4;
  --brand: #1f766e;
  --brand-strong: #145b55;
  --brand-soft: #dff1ee;
  --warm: #f4eee5;
  --danger: #a33c43;
  /* 안내 단계: 차분함이 기본, 병원·응급만 강하게 */
  --info: var(--brand);
  --info-soft: var(--brand-soft);
  --watch: #8a6414;
  --watch-soft: #f6eedb;
  --vet: #a8501f;
  --vet-soft: #f8e7dc;
  --emergency: var(--danger);
  --emergency-soft: #f7e3e4;

  /* 간격 (4px 단위) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  /* 글자 */
  --fs-xs: 13px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 18px; --fs-xl: 24px; --fs-2xl: 32px;
  --track-tight: -0.04em;
  /* 모양 */
  --radius: 18px; --radius-md: 14px; --radius-sm: 10px; --pill: 999px;
  --shadow-lg: 0 22px 70px rgba(23, 55, 51, .16);
  --tap: 44px; --btn: 52px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); --full-h: 100vh;
}
@supports (height: 100dvh) { :root { --full-h: 100dvh; } }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-md)/1.5 Pretendard, "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.fine { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s5); line-height: 1.6; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- 로그인 (프로토타입 첫 화면 구성) */
.screen { min-height: var(--full-h); display: flex; padding: var(--s8) var(--s5) max(var(--s8), var(--safe-bottom)); background: var(--warm); }
.login-box { width: 100%; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; }
.mark { font-weight: 800; font-size: var(--fs-md); letter-spacing: .08em; color: var(--brand-strong); margin-bottom: auto; padding-bottom: var(--s8); }
.hero { font-size: 34px; line-height: 1.2; font-weight: 800; letter-spacing: -0.06em; margin: 0 0 var(--s3); }
.lede { color: var(--muted); margin: 0 0 var(--s8); }
#login-form { display: flex; flex-direction: column; gap: var(--s3); text-align: left; }

/* ---------------------------------------------------------------- 입력 요소 */
input, select, textarea { width: 100%; min-height: 48px; padding: var(--s3) 14px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 104px; line-height: 1.55; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--brand); }
label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin: var(--s4) 0 6px; }
.row { display: flex; gap: var(--s2); align-items: center; }
.row > * { flex: 1; min-width: 0; }
.check-row { display: flex; align-items: center; gap: var(--s2); color: var(--ink); font-weight: 500; margin-top: var(--s4); }

.btn { min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--brand-strong); padding: 0 var(--s4); border-radius: var(--radius-md); cursor: pointer; font-weight: 700;
  transition: transform .12s var(--ease), background .15s var(--ease); }
.btn:active { transform: scale(.98); }
.btn.primary { min-height: var(--btn); background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 800; }
.btn.primary:active { background: var(--brand-strong); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn.block { width: 100%; }
.btn.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; background: transparent; color: var(--brand-strong);
  font-weight: 800; cursor: pointer; flex: none; display: grid; place-items: center; }

/* ---------------------------------------------------------------- 상단 */
.top { position: sticky; top: 0; z-index: 5; background: rgba(233, 240, 239, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4) var(--s2); padding-top: max(var(--s3), var(--safe-top)); }
.pets { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px; }
.pets::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: var(--tap); display: inline-flex; align-items: center; border: 0; background: none; padding: 0 var(--s3);
  cursor: pointer; white-space: nowrap; position: relative; font-weight: 700; font-size: var(--fs-lg); color: var(--muted); letter-spacing: var(--track-tight); }
.chip:first-child { padding-left: 0; }
.chip.add { font-size: var(--fs-sm); color: var(--brand-strong); }
.chip.active { color: var(--ink); font-weight: 800; }
.chip .badge { margin-left: 4px; align-self: flex-start; margin-top: 6px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  border-radius: var(--pill); min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 4px; }
.job-bar { margin: 0 var(--s4) var(--s2); padding: var(--s2) var(--s3); background: var(--brand-soft); color: var(--brand-strong); border-radius: var(--pill);
  font-size: var(--fs-sm); font-weight: 600; display: flex; gap: var(--s2); align-items: center; }
.job-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1s infinite alternate; flex: none; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }

main { padding: var(--s1) var(--s4) 112px; max-width: 640px; margin: 0 auto; }
.sh { margin: var(--s8) 0 var(--s3); display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.sh h2 { font-size: var(--fs-lg); font-weight: 800; letter-spacing: var(--track-tight); margin: 0; }
.sh p { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
h3 { font-size: var(--fs-md); font-weight: 800; margin: var(--s4) 0 var(--s2); }
.card { background: var(--surface); border-radius: var(--radius); padding: var(--s4); margin-bottom: var(--s2); }
.card.soft { background: transparent; border: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: var(--s8) var(--s2); }
.note { background: var(--warm); border-radius: var(--radius-md); padding: var(--s3) 14px; font-size: var(--fs-sm); line-height: 1.55; }
.note.brand { background: var(--brand-soft); color: var(--brand-strong); }

/* 반려동물 요약 */
.hello { padding: var(--s4) 0 var(--s2); }
.hello .name { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.06em; line-height: 1.15; }
.hello .sub { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s1); }

/* ---------------------------------------------------------------- 하단 탭 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); padding-bottom: var(--safe-bottom); }
.tabbar button { flex: 1; min-height: 58px; border: 0; background: none; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tabbar button svg.i { width: 22px; height: 22px; }
.tabbar button.active { color: var(--brand-strong); font-weight: 800; }
.tabbar button.add { color: var(--brand-strong); }
.tabbar button.add .plus { width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.tabbar button.add .plus svg.i { width: 20px; height: 20px; stroke-width: 2.2; }

/* ---------------------------------------------------------------- 안내 카드 */
.alert.vet { background: var(--vet-soft); }
.alert.emergency { background: var(--emergency-soft); }
.alert.stale { opacity: .55; }
.alert .head { display: flex; gap: var(--s2); align-items: flex-start; }
.alert .title { font-weight: 800; font-size: var(--fs-md); letter-spacing: -0.02em; flex: 1; line-height: 1.4; }
.lv { font-size: var(--fs-xs); font-weight: 800; border-radius: 7px; padding: 3px 7px; flex: none; line-height: 1.3; }
.lv.info { background: var(--info-soft); color: var(--brand-strong); }
.lv.watch { background: var(--watch-soft); color: var(--watch); }
.lv.vet { background: var(--vet); color: #fff; }
.lv.emergency { background: var(--emergency); color: #fff; }
.meta { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s1); }
.sec { margin-top: var(--s3); font-size: var(--fs-sm); }
.sec b { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); display: block; margin-bottom: 3px; }
.sec ul { margin: 0; padding-left: 18px; }
.sec li + li { margin-top: 2px; }
.ref { display: inline-flex; align-items: center; min-height: 22px; font-size: var(--fs-xs); font-weight: 700; background: var(--brand-soft); color: var(--brand-strong);
  border-radius: 7px; padding: 0 7px; margin: 1px 2px; cursor: pointer; border: 0; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: var(--fs-xs); font-weight: 600; border-radius: 7px; padding: 1px 7px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); margin: 2px 4px 0 0; }
.actions-end { display: flex; justify-content: flex-end; margin-top: var(--s3); }
details { margin-top: var(--s2); }
details summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; padding: var(--s2) 0; min-height: var(--tap); display: flex; align-items: center; }

/* 평소 범위 */
.metrics { background: var(--surface); border-radius: var(--radius); padding: 0 var(--s4); }
.metric { display: grid; grid-template-columns: minmax(0, 1fr) 80px 64px; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.metric:first-child { border-top: 0; }
.metric .name { font-weight: 700; }
.metric .st { font-size: var(--fs-xs); color: var(--muted); }
.metric.pending .st { color: var(--watch); }
.metric .val { font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; }
.metric svg { width: 80px; height: 28px; display: block; }

/* ---------------------------------------------------------------- 기록 */
.day-h { font-size: var(--fs-sm); color: var(--muted); margin: var(--s5) 2px var(--s2); font-weight: 800; }
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.rec { width: 100%; text-align: left; display: flex; gap: var(--s3); align-items: flex-start; background: none; border: 0; border-top: 1px solid var(--line);
  padding: var(--s3) var(--s4); cursor: pointer; }
.rec:first-child { border-top: 0; }
.rec:active { background: var(--surface-soft); }
.rec .k { font-weight: 700; min-width: 48px; color: var(--muted); }
.rec .body { flex: 1; min-width: 0; }
.rec .v { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec .t { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.rec img { width: 54px; height: 54px; object-fit: cover; border-radius: var(--radius-sm); flex: none; }

/* ---------------------------------------------------------------- 입력 화면 */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: #dbe6e4; border-radius: var(--radius-md); padding: 4px; gap: 4px; margin: var(--s3) 0 var(--s4); }
.seg button { border: 0; background: none; min-height: 40px; border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 800; }
.kinds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.kinds button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); min-height: var(--tap); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.kinds button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flags label { margin: 0; display: inline-flex; gap: 6px; align-items: center; min-height: 36px; border: 1px solid var(--line); border-radius: var(--pill);
  padding: 0 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--ink); background: var(--surface); cursor: pointer; }
.flags input { width: 16px; height: 16px; margin: 0; }
.flags label.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s2); }
.tools .btn { width: 100%; margin: 0; }
.file-name { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; min-height: 1em; }
.cand { border: 1px dashed #bcd2ce; box-shadow: none; }
.q { background: var(--watch-soft); color: #5e450f; border-radius: var(--radius-sm); padding: var(--s2) var(--s3); margin: var(--s2) 0 0; font-size: var(--fs-sm); }
.q.vet { background: var(--vet-soft); color: var(--vet); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s2); }
.photo-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.photo-cmp figure { margin: 0; }
.photo-cmp img, .photo-one { width: 100%; border-radius: var(--radius-sm); display: block; aspect-ratio: 1; object-fit: cover; background: var(--surface-soft); }
.photo-cmp figcaption { font-size: var(--fs-xs); color: var(--muted); text-align: center; margin-top: 4px; }
.upload { display: flex; align-items: center; justify-content: center; gap: var(--s2); margin-top: var(--s4); }

/* 기억 */
.overview { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.02em; line-height: 1.45; margin: var(--s2) 0 0; }
.mem-item { padding: var(--s2) 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.mem-item:first-of-type { border-top: 0; }

/* 대화 */
.chat { display: flex; flex-direction: column; gap: var(--s2); }
.bubble { max-width: 86%; padding: var(--s3) 14px; border-radius: 18px 18px 18px 6px; background: var(--surface); white-space: pre-wrap; font-size: 15px; }
.bubble.me { align-self: flex-end; background: var(--brand-strong); color: #fff; border-radius: 18px 18px 6px 18px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: var(--s3); }
.chat-input { position: fixed; left: 0; right: 0; bottom: calc(58px + var(--safe-bottom)); background: rgba(233, 240, 239, .95);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); padding: var(--s2) var(--s4); display: flex; gap: var(--s2); max-width: 640px; margin: 0 auto; }
.chat-input input { flex: 1; border-radius: var(--pill); }
.chat-input .btn { border-radius: var(--pill); min-height: 48px; }

/* ---------------------------------------------------------------- 모달·토스트 */
.modal { position: fixed; inset: 0; background: rgba(23, 35, 33, .38); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s var(--ease); }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: calc(var(--full-h) * .92); overflow-y: auto; border-radius: 24px 24px 0 0;
  padding: var(--s3) var(--s4) calc(var(--s5) + var(--safe-bottom)); animation: up .26s var(--ease); }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: var(--pill); background: #c5d3d0; margin: 0 auto var(--s3); }
.sheet h2 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: var(--track-tight); margin: var(--s1) 0 var(--s2); }
.sheet .foot { display: flex; gap: var(--s2); margin-top: var(--s5); }
.sheet .foot .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: var(--s3) var(--s4); border-radius: var(--radius-md); z-index: 30; font-size: var(--fs-sm); font-weight: 600; width: max-content; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow-lg); }
.check { padding-left: 20px; }
.check li { margin: var(--s2) 0; }
.check b { color: var(--brand-strong); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- 큰 화면: 가운데 폰 목업 안에 표시
   휴대폰에서 열면 목업 없이 전체 화면. transform 이 있는 .device 가 fixed 요소(탭바·시트·토스트)의 기준이 된다. */
.page-note { display: none; }
@media (min-width: 720px) and (min-height: 560px) {
  html, body { height: 100%; overflow: hidden; background: #dfe7e5; }
  body { display: flex; align-items: center; justify-content: center; }
  .device { container-type: size; --full-h: 100cqh; --safe-top: 34px; --safe-bottom: 14px;
    position: relative; transform: translateZ(0); flex: none;
    height: min(844px, calc(100vh - 48px)); width: min(390px, calc((100vh - 48px) * 390 / 844));
    border: 11px solid #1b2422; border-radius: 54px; background: var(--bg); overflow: hidden;
    box-shadow: 0 0 0 1px #3a4643, 0 30px 80px rgba(23, 35, 33, .22); }
  .device::before { content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%); width: 104px; height: 28px;
    border-radius: var(--pill); background: #1b2422; z-index: 50; pointer-events: none; }
  .device-screen { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
  .device-screen::-webkit-scrollbar { display: none; }
  .sheet { border-radius: 24px 24px 0 0; }
  .page-note { display: block; position: absolute; left: calc(50% + 245px); top: 50%; transform: translateY(-50%); margin: 0; max-width: 220px; color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; }
  .page-note b { display: block; color: var(--brand-strong); font-size: var(--fs-md); letter-spacing: .08em; margin-bottom: var(--s2); }
}
@media (min-width: 720px) and (min-height: 560px) and (max-width: 1000px) { .page-note { display: none; } }
