/* ============================================================
   Patient Inside — Design System v3 "온기 (Ondo)"
   따뜻한 노을빛 테라코타 · 종이 질감 · 손편지 감성
   ============================================================ */

:root {
  --brand: #c74f2e;
  --brand-soft: #d96540;
  --brand-deep: #a63f24;
  --brand-ink: #6d2b1c;
  --paper: #fbf5ec;
  --cream: #fdf8f1;
  --line: rgba(150, 105, 70, .16);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: var(--paper);
  font-feature-settings: 'ss05';
  letter-spacing: -0.011em;
}

/* 감성 세리프 — 제목·인용에 사용 */
.font-display { font-family: 'Gowun Batang', Pretendard, serif; letter-spacing: -0.02em; }

/* ---------- ambient sunset background ---------- */
#bg-aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(46rem 32rem at 88% -10%, rgba(229, 128, 92, .16), transparent 62%),
    radial-gradient(38rem 28rem at -12% 28%, rgba(246, 200, 178, .30), transparent 60%),
    radial-gradient(32rem 26rem at 55% 112%, rgba(217, 101, 64, .09), transparent 55%),
    radial-gradient(24rem 18rem at 30% -6%, rgba(250, 214, 137, .18), transparent 58%),
    var(--paper);
}

/* 따뜻한 종이 결 */
#bg-aurora::after {
  content: ''; position: absolute; inset: 0; opacity: .55; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.42 0 0 0 0 0.30 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- warm paper card ---------- */
.card {
  background: rgba(255, 253, 249, .86);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .9);
  outline: 1px solid var(--line);
  outline-offset: -1px;
  border-radius: 1.35rem;
  box-shadow: 0 1px 2px rgba(93, 58, 34, .05), 0 6px 20px rgba(93, 58, 34, .06);
  transition: box-shadow .3s var(--ease-out), transform .3s var(--ease-out);
}
a.card:hover, a.card:focus-visible {
  transform: translateY(-2px) rotate(-.15deg);
  box-shadow: 0 2px 4px rgba(93,58,34,.06), 0 14px 34px rgba(93,58,34,.13);
}
a.card:active { transform: translateY(0) scale(.99); }

/* hero variant — 노을빛 패널 */
.card-hero {
  background: linear-gradient(145deg, #e5805c 0%, #d96540 42%, #b8461f 100%);
  border: none; outline: none; color: #fff;
  border-radius: 1.6rem;
  box-shadow: 0 4px 12px rgba(199,79,46,.28), 0 16px 40px rgba(199,79,46,.24);
  position: relative; overflow: hidden;
}
.card-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(22rem 13rem at 112% -22%, rgba(255, 226, 178, .35), transparent 62%),
    radial-gradient(15rem 11rem at -12% 122%, rgba(255,255,255,.10), transparent 55%);
}
/* 히어로에 은은한 햇살 링 */
.card-hero::after {
  content: ''; position: absolute; right: -3.5rem; top: -3.5rem; width: 11rem; height: 11rem;
  border-radius: 9999px; pointer-events: none;
  border: 1.5px solid rgba(255, 235, 205, .35);
  box-shadow: 0 0 0 1.6rem rgba(255, 235, 205, .08), 0 0 0 3.4rem rgba(255, 235, 205, .05);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: 1rem; font-weight: 700; cursor: pointer;
  transition: transform .18s var(--ease-spring), box-shadow .25s var(--ease-out),
              background-color .18s, border-color .18s, color .18s;
  will-change: transform;
}
.btn:active { transform: scale(.965); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #e5805c 0%, #cf5330 100%);
  color: #fff; padding: .8rem 1.3rem;
  box-shadow: 0 1px 2px rgba(199,79,46,.35), 0 6px 16px rgba(199,79,46,.30),
              inset 0 1px 0 rgba(255,255,255,.28);
  text-shadow: 0 1px 1px rgba(90,30,10,.15);
}
.btn-primary:hover { box-shadow: 0 2px 4px rgba(199,79,46,.4), 0 10px 26px rgba(199,79,46,.38), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  background: rgba(255,253,249,.75); color: #6b584a;
  padding: .65rem 1.05rem; border: 1px solid rgba(150,105,70,.2);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: #fffdf9; border-color: rgba(150,105,70,.34); color: #3c2f26; }

.btn-danger {
  background: linear-gradient(180deg, #e35d5d, #cf3d3d); color: #fff;
  padding: .8rem 1.3rem;
  box-shadow: 0 1px 2px rgba(207,61,61,.35), 0 6px 16px rgba(207,61,61,.25), inset 0 1px 0 rgba(255,255,255,.2);
}

/* ---------- inputs ---------- */
.input {
  width: 100%; border: 1.5px solid rgba(150,105,70,.2); border-radius: 1rem;
  padding: .75rem 1rem; background: rgba(255,253,249,.9); outline: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input:hover { border-color: rgba(150,105,70,.36); }
.input:focus {
  border-color: var(--brand-soft); background: #fffdf9;
  box-shadow: 0 0 0 4px rgba(217,101,64,.14);
}
.input::placeholder { color: #c0ac97; }

/* ---------- badges & category chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 700; border-radius: 9999px; padding: .2rem .65rem;
  letter-spacing: -.01em;
}
.cat-pain      { background: linear-gradient(180deg,#fdf1f1,#fbe1e1); color:#b34040; box-shadow: inset 0 0 0 1px rgba(179,64,64,.15); }
.cat-joy       { background: linear-gradient(180deg,#fef8e7,#fdefc3); color:#a3762a; box-shadow: inset 0 0 0 1px rgba(163,118,42,.16); }
.cat-want      { background: linear-gradient(180deg,#eef5fb,#dcebf7); color:#3a6ea5; box-shadow: inset 0 0 0 1px rgba(58,110,165,.15); }
.cat-can_do    { background: linear-gradient(180deg,#f0f8ef,#ddefdb); color:#4a7c46; box-shadow: inset 0 0 0 1px rgba(74,124,70,.16); }
.cat-cannot_do { background: linear-gradient(180deg,#f7f2fa,#eee3f4); color:#8455a0; box-shadow: inset 0 0 0 1px rgba(132,85,160,.15); }

/* category accent bars on insight cards */
.ins-card { position: relative; overflow: hidden; }
.ins-card::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; border-radius: 4px 0 0 4px; }
.ins-pain::before      { background: linear-gradient(180deg,#e08585,#b34040); }
.ins-joy::before       { background: linear-gradient(180deg,#eec55f,#a3762a); }
.ins-want::before      { background: linear-gradient(180deg,#7fa8d0,#3a6ea5); }
.ins-can_do::before    { background: linear-gradient(180deg,#8fbf8a,#4a7c46); }
.ins-cannot_do::before { background: linear-gradient(180deg,#b48ecb,#8455a0); }

/* ---------- filter pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; border-radius: 9999px; padding: .42rem .95rem;
  white-space: nowrap; cursor: pointer;
  background: rgba(255,253,249,.8); color: #6b584a;
  border: 1px solid rgba(150,105,70,.18);
  transition: all .2s var(--ease-out);
}
.pill:hover { border-color: rgba(199,79,46,.42); color: var(--brand-deep); }
.pill.active {
  background: linear-gradient(180deg,#e5805c,#cf5330); color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(199,79,46,.35);
}

/* ---------- bottom nav ---------- */
.nav-shell {
  background: rgba(255,252,247,.86);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid rgba(150,105,70,.13);
  box-shadow: 0 -6px 24px rgba(93,58,34,.07);
}
.nav-item { position: relative; color: #b3a08d; transition: color .2s, transform .2s var(--ease-spring); }
.nav-item:active { transform: scale(.92); }
.nav-item.active { color: var(--brand-deep); }
.nav-item.active::after {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 1.4rem; height: 3px; border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg,#e5805c,#c74f2e);
}

/* center mic button — 온기 오브 */
.nav-mic {
  width: 3.4rem; height: 3.4rem; margin-top: -1.4rem;
  border-radius: 9999px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg,#eda06f,#d96540 55%,#b8461f);
  color: #fff; font-size: 1.15rem;
  box-shadow: 0 3px 8px rgba(199,79,46,.4), 0 10px 24px rgba(199,79,46,.35),
              inset 0 1.5px 0 rgba(255,235,205,.45);
  transition: transform .2s var(--ease-spring), box-shadow .25s;
}
.nav-mic:hover { transform: translateY(-2px) scale(1.04); }
.nav-mic:active { transform: scale(.94); }

/* ---------- header ---------- */
.app-header {
  background: rgba(251,245,236,.8);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid rgba(150,105,70,.11);
}

/* ---------- motion ---------- */
.fade-in { animation: fadein .4s var(--ease-out) both; }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.stagger > * { animation: fadein .45s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(7) { animation-delay: .26s; }
.stagger > *:nth-child(8) { animation-delay: .30s; }

.rec-pulse { animation: recpulse 1.6s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* recording ring ripple — 촛불처럼 번지는 링 */
.rec-ring { position: relative; }
.rec-ring::before, .rec-ring::after {
  content: ''; position: absolute; inset: 0; border-radius: 9999px;
  border: 2px solid rgba(217,101,64,.5); animation: ripple 2s var(--ease-out) infinite;
}
.rec-ring::after { animation-delay: 1s; }
@keyframes ripple { from { transform: scale(1); opacity: .8; } to { transform: scale(1.55); opacity: 0; } }

/* processing shimmer bar */
.shimmer {
  position: relative; overflow: hidden; background: #f0e3d0; border-radius: 9999px; height: 6px;
}
.shimmer::after {
  content: ''; position: absolute; inset: 0; width: 45%;
  background: linear-gradient(90deg, transparent, #e5805c, transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { transform: translateX(-110%); } to { transform: translateX(320%); } }

/* skeleton loading */
.skeleton {
  border-radius: 1.35rem; background: linear-gradient(100deg, #f2e6d4 40%, #faf2e6 50%, #f2e6d4 60%);
  background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite;
}
@keyframes skel { from { background-position: 120% 0; } to { background-position: -80% 0; } }

/* stat ring (conic gauge) */
.ring { position: relative; border-radius: 9999px; display: grid; place-items: center; }
.ring::before {
  content: ''; position: absolute; inset: 5px; border-radius: 9999px; background: #fffdf9;
}
.ring > * { position: relative; }

/* toast */
.toast {
  position: fixed; bottom: 6.5rem; left: 50%; transform: translateX(-50%);
  z-index: 60; padding: .7rem 1.15rem; border-radius: 1rem;
  font-size: .84rem; font-weight: 600; color: #fff;
  background: rgba(62,42,30,.93);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(62,42,30,.3);
  animation: toastin .35s var(--ease-spring) both;
}
.toast.bad { background: rgba(179,52,52,.94); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px) scale(.94); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* empty state */
.empty {
  text-align: center; padding: 2.2rem 1.2rem; color: #b3a08d;
  border: 1.5px dashed rgba(150,105,70,.26); border-radius: 1.35rem;
  background: rgba(255,253,249,.45);
}
.empty i { font-size: 1.6rem; display: block; margin-bottom: .55rem; opacity: .55; }

/* divider label */
.section-label {
  display: flex; align-items: center; gap: .6rem;
  font-size: .78rem; font-weight: 800; color: #82705f;
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: .65rem;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(150,105,70,.2), transparent); }

/* 손편지 인용 블록 */
.quote-paper {
  background: linear-gradient(160deg,#faf0e2,#f5e6d2);
  box-shadow: inset 0 0 0 1px rgba(150,105,70,.12);
  border-radius: 1.15rem;
}

/* scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(150,105,70,.22); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(150,105,70,.38); }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* print */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; inset: 0; padding: 2rem; }
  #bg-aurora { display: none; }
}

/* ---------- mobile optimization ---------- */
/* 터치 반응성: 탭 하이라이트 제거 + 더블탭 줌 방지 */
a, button, .pill, .nav-item, .card, label { -webkit-tap-highlight-color: transparent; }
a, button, input, select, textarea, .pill { touch-action: manipulation; }

/* .input의 width:100%가 너비 유틸리티(w-20 등)를 덮는 버그 수정 */
.input.w-20 { width: 5rem; }
.input.w-16 { width: 4rem; }
.input.w-24 { width: 6rem; }

/* iOS 자동 줌 방지: 터치 기기에서 입력란 글꼴 16px 미만이면 포커스 시 강제 줌 발생 */
@media (pointer: coarse) {
  .input, input, select, textarea { font-size: 16px !important; }
  /* 작은 탭 타겟 최소 높이 확보 */
  .pill { padding: .6rem 1.05rem; font-size: .8rem; }
  /* 텍스트 링크 터치 여백 (레이아웃 안 깨지게 음수 마진 상쇄) */
  main a:not(.btn):not(.card):not(.pill):not(.nav-item),
  form a, p a { padding: .5rem .25rem; margin: -.5rem -.25rem; }
  /* 카드 내 리스트형 링크 터치 높이 */
  .card a.flex { min-height: 44px; align-items: center; }
}

/* PWA/노치 대응: 상단 헤더 safe-area */
.app-header { padding-top: max(.75rem, env(safe-area-inset-top)); }

/* 모바일 스크롤 관성 + 가로 오버플로 방지 */
html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }

/* 좁은 화면(320~360px)에서 여백 압축 */
@media (max-width: 360px) {
  main { padding-left: .75rem; padding-right: .75rem; }
  .card { border-radius: 1rem; }
}
