/* ═══════════════════════════════════════════════════════════════
   KONGI HOME v3 — 2026-07 목업 리디자인
   홈(#screenScan)·원두 분석 결과(#screenResult) 전용 스킨.
   style.css / attendance_ui.css 뒤에 로드되어 두 화면만 덮어쓴다.
═══════════════════════════════════════════════════════════════ */

:root {
  --kh-bg:        #FAF3E1;   /* 화면 아이보리 */
  --kh-bg-deep:   #F3E5C6;   /* 살짝 깊은 크림 (칩·서브 서피스) */
  --kh-card:      #FDF8EA;   /* 카드 아이보리 */
  --kh-brown:     #774627;   /* 프라이머리 브라운 (스캔 카드·CTA) */
  --kh-brown-2:   #5E3A22;   /* 아웃라인 브라운 */
  --kh-ink:       #46281A;   /* 가장 진한 텍스트 */
  --kh-ink-soft:  #6E4A31;   /* 보조 텍스트 */
  --kh-cream:     #F9EFDA;   /* 브라운 위 텍스트 */
  --kh-mint:      #C9E9CE;   /* 민트 칩 */
  --kh-mint-deep: #A8DBB4;
  --kh-green:     #55BD82;   /* 스캔 완료 체크 */
  --kh-line:      rgba(94, 58, 34, .55);
  --kh-line-soft: rgba(94, 58, 34, .16);
  --kh-r-lg: 26px;
  --kh-r-md: 20px;
  --kh-r-sm: 14px;
  --kh-shadow: 0 10px 26px -14px rgba(70, 40, 26, .28);
  /* 목업 폰트 = Pretendard 굵은 웨이트 (제목 800 / 라벨 700 / 서브 600) */
  --f-kongi: 'PretendardKR', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── 화면 배경 ─────────────────────────────────────────────── */
/* v2 카페 씬 배경(!important) 무효화 */
#screenScan { background: var(--kh-bg) !important; }
#screenResult { background: var(--kh-bg); }

/* ═══════════════════════════════════════════════════════════════
   1. 홈 (#screenScan)
═══════════════════════════════════════════════════════════════ */
#screenScan .kh-body {
  justify-content: flex-start;
  padding: 1.6rem 1.35rem 1.2rem;
  gap: 0;
}
.kh-fold { gap: 0; }

.kh-home {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.kh-home[hidden] { display: none; }

/* ── 헤더: 인사 + 헤드라인 + 콩이 ──────────────────────────── */
.kh-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-bottom: 1.15rem;
}
.kh-greet {
  font-family: var(--f-kongi);
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--kh-ink-soft);
  margin-bottom: .3rem;
  letter-spacing: .01em;
}
.kh-title {
  font-family: var(--f-kongi);
  font-weight: 800;                 /* Jua는 단일 웨이트 */
  font-size: 1.78rem;
  line-height: 1.28;
  color: var(--kh-ink);
  letter-spacing: .005em;
}
/* 살아있는 콩이 — 카페 씬의 fixed 배치를 헤더 인라인으로 재정의 */
#screenScan .kh-kongi {
  position: relative;
  left: auto; top: auto;
  height: auto;
  transform: none;
  flex: 0 0 auto;
  width: 88px;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(70, 40, 26, .18));
}
#screenScan .kh-kongi .kx-sprite {
  width: 100%;
  height: auto;
  animation: khKongiFloat 3.6s ease-in-out infinite;
}
@keyframes khKongiFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* ── 대형 스캔 카드 ────────────────────────────────────────── */
#screenScan .scan-btn-primary.kh-scancard {
  max-width: none;
  width: 100%;
  min-height: 218px;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 2.1rem 1.4rem 2rem;
  background: linear-gradient(168deg, #7E4C2B 0%, #74441f 58%, #6A3D20 100%);
  border-radius: var(--kh-r-lg);
  box-shadow: 0 14px 30px -12px rgba(94, 58, 34, .45),
              inset 0 1.5px 0 rgba(255, 244, 222, .18);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
#screenScan .scan-btn-primary.kh-scancard:hover {
  background: linear-gradient(168deg, #7E4C2B 0%, #74441f 58%, #6A3D20 100%);
  transform: translateY(-2px);
  box-shadow: 0 18px 34px -12px rgba(94, 58, 34, .5),
              inset 0 1.5px 0 rgba(255, 244, 222, .18);
}
#screenScan .scan-btn-primary.kh-scancard:active { transform: scale(.985); }

/* 카드 배경 장식 원두 */
.kh-scan-bean {
  position: absolute;
  color: #8B5A36;
  opacity: .5;
  pointer-events: none;
}
.kh-scan-bean-1 { width: 74px;  right: -14px; top: -10px;   transform: rotate(24deg); }
.kh-scan-bean-2 { width: 56px;  left: -10px;  bottom: 14px; transform: rotate(-28deg); }
.kh-scan-bean-3 { width: 40px;  right: 42px;  bottom: -12px; transform: rotate(10deg); }

.kh-scan-cam {
  position: relative;
  width: 52px; height: 52px;
  color: var(--kh-cream);
  pointer-events: none;
}
.kh-scan-cam svg { width: 100%; height: 100%; }

#screenScan .sbp-label.kh-scan-title {
  font-family: var(--f-kongi);
  font-weight: 800;
  font-size: 1.62rem;
  letter-spacing: .02em;
  color: var(--kh-cream);
  position: relative;
}
#screenScan .sbp-sub.kh-scan-sub {
  display: block;
  font-family: var(--f-kongi);
  font-weight: 600;
  font-size: .98rem;
  color: rgba(249, 239, 218, .82);
  letter-spacing: .01em;
  position: relative;
  pointer-events: none;
}

/* ── 섹션 공통 ─────────────────────────────────────────────── */
.kh-sec { width: 100%; margin-top: 1.6rem; }
.kh-sec-title {
  font-family: var(--f-kongi);
  font-weight: 800;
  font-size: 1.22rem;
  color: var(--kh-ink);
  margin-bottom: .75rem;
  text-align: left;
}

/* ── 내 원두 서재 (가로 스크롤 칩) ─────────────────────────── */
.kh-shelf {
  display: flex;
  gap: 11px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.kh-shelf::-webkit-scrollbar { display: none; }
.kh-bean-chip {
  flex: 0 0 auto;
  min-width: 106px;
  min-height: 72px;
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--kh-card);
  border: 2px solid var(--kh-line);
  border-radius: 18px;
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--kh-ink);
  cursor: pointer;
  word-break: keep-all;
  max-width: 150px;
  box-shadow: 0 3px 0 rgba(94, 58, 34, .12);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.kh-bean-chip:hover  { background: #FFFBEF; transform: translateY(-2px); box-shadow: 0 5px 0 rgba(94,58,34,.14); }
.kh-bean-chip:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(94,58,34,.14); }
.kh-bean-add { border-style: dashed; color: var(--kh-ink-soft); }
.kh-add-ico {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--kh-bg-deep);
  border: 1.5px solid var(--kh-line);
  font-size: 1.05rem;
  line-height: 1;
}

/* ── 오늘의 추천 레시피 카드 ───────────────────────────────── */
#screenScan .kh-today {
  position: relative;
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: row;         /* .ks-fab(세로 스택) 재정의 */
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: .85rem 1rem;
  background: #FFFDF4;
  border: 1.5px solid var(--kh-line-soft);
  border-radius: var(--kh-r-md);
  box-shadow: var(--kh-shadow);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
#screenScan .kh-today:hover  { transform: translateY(-2px); }
#screenScan .kh-today:active { transform: scale(.985); }
.kh-today-ico { width: 46px; height: 46px; flex: 0 0 auto; }
.kh-today-ico svg { width: 100%; height: 100%; }
.kh-today-tx {
  flex: 1;
  text-align: left;
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: 1.06rem;
  color: var(--kh-ink);
  letter-spacing: .01em;
}
.kh-today-avatar {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--kh-mint);
  overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  border: 1.5px solid rgba(94, 58, 34, .25);
}
.kh-today-avatar img { width: 82%; height: auto; transform: translateY(3px); }

/* ── 스캔 진행 영역 리스킨 ─────────────────────────────────── */
#screenScan .scan-progress-area { max-width: 420px; margin-top: 1rem; }
#screenScan .scan-preview-img {
  border-radius: var(--kh-r-lg) !important;
  border: 2.5px solid var(--kh-line);
  box-shadow: var(--kh-shadow);
}
#screenScan .scanning-label {
  font-family: var(--f-kongi);
  font-weight: 700;
  color: var(--kh-ink-soft);
}
#screenScan .scanning-bar-fill { background: var(--kh-brown); }

/* 에러 박스 */
#screenScan .scan-error-box { max-width: 420px; }

/* 스트릭 카드·미션 카드 (attendance_ui) 를 새 톤으로 */
#scanBody .ks-streak-card,
#scanBody .db-mission-card {
  background: var(--kh-card);
  border: 1.5px solid var(--kh-line-soft);
  border-radius: var(--kh-r-md);
}

/* ── 하단 탭바 (홈·스캔·레시피·마이) ───────────────────────── */
.ks-tabbar {
  background: #FBF4E3;
  border-top: 1.5px solid rgba(94, 58, 34, .14);
}
.ks-tab { color: #A98D6F; }
.ks-tab .ks-tab-ico { height: 30px; padding: 0 16px; }
.ks-tab.active { color: var(--kh-brown); }
.ks-tab.active .ks-tab-ico { background: rgba(119, 70, 39, .12); }
.ks-tab-label {
  font-family: var(--f-kongi);
  font-weight: 600;
  font-size: .74rem;
  letter-spacing: .02em;
}
.ks-tab.active .ks-tab-label { font-weight: 400; color: var(--kh-brown); }

/* 마이 패널 톤 정리 */
.ks-mypanel { background: #FBF4E3; }

/* ═══════════════════════════════════════════════════════════════
   2. 원두 분석 결과 (#screenResult)
═══════════════════════════════════════════════════════════════ */
#screenResult .kr-nav {
  background: transparent;
  border-bottom: none;
  padding: 1rem 1.2rem .4rem;
  display: flex;
  align-items: center;
}
#screenResult .kr-nav .nav-title {
  font-family: var(--f-kongi);
  font-weight: 800;
  font-size: 1.28rem;
  color: var(--kh-ink);
  text-align: center;
}
#screenResult .kr-nav .back-btn {
  border: none;
  background: transparent;
  color: var(--kh-ink);
  font-size: 1.5rem;
  width: 40px; height: 40px;
}
.kr-nav-spacer { width: 40px; flex: 0 0 auto; }

.kr-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: .4rem 1.35rem calc(1.6rem + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
}
.kr-body > * { flex-shrink: 0; }

/* ── 스캔 사진 + 완료 오버레이 ─────────────────────────────── */
.kr-photo {
  position: relative;
  width: 100%;
  height: 218px;
  border-radius: var(--kh-r-lg);
  overflow: hidden;
  background: var(--kh-bg-deep);
  box-shadow: var(--kh-shadow);
}
.kr-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.kr-photo-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(40, 24, 12, .12), rgba(40, 24, 12, .34));
}
.kr-scan-done {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.kr-check {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--kh-green);
  border: 3px solid rgba(255, 255, 255, .85);
  box-shadow: 0 6px 18px -4px rgba(30, 80, 50, .5);
  display: flex; align-items: center; justify-content: center;
  animation: krPop .45s cubic-bezier(.34, 1.56, .64, 1) both;
}
.kr-check svg { width: 34px; height: 34px; }
@keyframes krPop {
  0%   { transform: scale(.3); opacity: 0; }
  100% { transform: scale(1);  opacity: 1; }
}
.kr-done-label {
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: 1.02rem;
  color: #FFF9EC;
  text-shadow: 0 1px 6px rgba(40, 24, 12, .55);
  letter-spacing: .03em;
}

/* ── 원두 이름 카드 ────────────────────────────────────────── */
.kr-namecard {
  margin-top: 1.15rem;
  background: var(--kh-card);
  border: 2.5px solid var(--kh-brown-2);
  border-radius: 22px;
  padding: 1.25rem 1.1rem 1.15rem;
  text-align: center;
  box-shadow: 0 4px 0 rgba(94, 58, 34, .14);
}
.kr-name {
  font-family: var(--f-kongi);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--kh-ink);
  line-height: 1.3;
  letter-spacing: .01em;
  word-break: keep-all;
}
.kr-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: .8rem;
}
.kr-chip {
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: .92rem;
  color: var(--kh-ink);
  background: var(--kh-bg-deep);
  border: 1.5px solid rgba(94, 58, 34, .35);
  border-radius: 12px;
  padding: .34rem .72rem;
  letter-spacing: .01em;
  white-space: nowrap;
}
.kr-chip-mint {
  background: var(--kh-mint);
  border-color: rgba(60, 120, 80, .35);
}

/* ── 콩이 코멘트 말풍선 ────────────────────────────────────── */
.kr-kongi-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1.35rem;
  padding: 0 .1rem;
}
.kr-kongi {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  filter: drop-shadow(0 6px 10px rgba(70, 40, 26, .18));
}
.kr-kongi img {
  width: 100%; height: auto; display: block;
  animation: khKongiFloat 3.8s ease-in-out infinite;
}
.kr-spark {
  position: absolute;
  color: #E5B54C;
  font-size: .95rem;
  animation: krTwinkle 2.2s ease-in-out infinite;
}
.kr-spark-a { top: -6px; left: -4px; }
.kr-spark-b { right: 2px; top: -2px; font-size: 1.1rem; animation-delay: .7s; }
@keyframes krTwinkle {
  0%, 100% { opacity: .25; transform: scale(.8); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
.kr-bubble {
  position: relative;
  flex: 1;
  background: #6F4226;
  border: 2px solid var(--kh-mint-deep);
  border-radius: 18px;
  padding: .95rem 1.05rem;
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: 1.06rem;
  line-height: 1.45;
  color: var(--kh-cream);
  white-space: pre-line;
  letter-spacing: .01em;
  box-shadow: var(--kh-shadow);
}
.kr-bubble::before {
  content: "";
  position: absolute;
  left: -11px; top: 50%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-right: 10px solid var(--kh-mint-deep);
}
.kr-bubble::after {
  content: "";
  position: absolute;
  left: -6px; top: 50%;
  transform: translateY(-50%);
  border: 5.5px solid transparent;
  border-right: 8px solid #6F4226;
}

/* ── 로스팅 확인 (신뢰도 낮을 때만) — 칩 스타일 ────────────── */
#screenResult .sr-roast-confirm {
  display: none;
  margin-top: 1.1rem;
  background: var(--kh-card);
  border: 1.5px solid var(--kh-line-soft);
  border-radius: var(--kh-r-md);
  padding: 1rem 1rem .95rem;
  text-align: center;
}
#screenResult .sr-roast-q {
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--kh-ink);
  margin-bottom: .3rem;
}
#screenResult .sr-roast-hint {
  font-size: .8rem;
  color: var(--kh-ink-soft);
  margin-bottom: .5rem;
  line-height: 1.45;
}
#screenResult .sr-roast-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: .55rem;
}
#screenResult .sr-roast-pill {
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: .95rem;
  color: var(--kh-ink);
  background: var(--kh-bg-deep);
  border: 1.5px solid rgba(94, 58, 34, .35);
  border-radius: 12px;
  padding: .45rem .95rem;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
#screenResult .sr-roast-pill:active { transform: scale(.95); }
#screenResult .sr-roast-pill.selected {
  background: var(--kh-mint);
  border-color: rgba(60, 120, 80, .45);
}

/* ── 추천 레시피 2열 카드 ─────────────────────────────────── */
.kr-sec { margin-top: 1.5rem; }
.kr-recipes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.kr-recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 1.9rem .8rem 1.05rem;
  background: #FFFDF4;
  border: 1.5px solid var(--kh-line-soft);
  border-radius: var(--kh-r-md);
  box-shadow: var(--kh-shadow);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.kr-recipe-card:hover  { transform: translateY(-2px); }
.kr-recipe-card:active { transform: scale(.97); }
.kr-more {
  position: absolute;
  top: 10px; right: 13px;
  font-size: .76rem;
  color: var(--kh-ink-soft);
  font-family: var(--f-sans);
}
.kr-recipe-ico { width: 62px; height: 62px; }
.kr-recipe-ico svg { width: 100%; height: 100%; }
.kr-recipe-name {
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--kh-ink);
  letter-spacing: .01em;
}
.kr-recipe-ratio {
  font-family: var(--f-num, sans-serif);
  font-weight: 600;
  font-size: .92rem;
  color: var(--kh-ink-soft);
}

/* ── CTA ──────────────────────────────────────────────────── */
.kr-cta {
  margin-top: 1.5rem;
  width: 100%;
  padding: 1.05rem;
  background: var(--kh-brown);
  color: var(--kh-cream);
  border: none;
  border-radius: 18px;
  font-family: var(--f-kongi);
  font-weight: 800;
  font-size: 1.22rem;
  letter-spacing: .03em;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px rgba(94, 58, 34, .5),
              inset 0 1.5px 0 rgba(255, 244, 222, .16);
  transition: transform .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.kr-cta:hover  { background: #6A3D20; transform: translateY(-1px); }
.kr-cta:active { transform: scale(.985); }
.kr-cta:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}
.kr-rescan {
  margin: .8rem auto 0;
  display: block;
  background: none;
  border: none;
  font-family: var(--f-kongi);
  font-weight: 700;
  font-size: .92rem;
  color: var(--kh-ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ── 좁은 화면 보정 ───────────────────────────────────────── */
@media (max-width: 360px) {
  .kh-title { font-size: 1.55rem; }
  #screenScan .kh-kongi { width: 74px; }
  #screenScan .sbp-label.kh-scan-title { font-size: 1.45rem; }
  .kr-kongi { width: 78px; }
}
