/* ============================================================
   우렁의사의 마음챙김 CBT — "따뜻한 힐링" 디자인 시스템
   세이지 그린 + 테라코타 파스텔 · 부드러운 카드 · 넉넉한 여백
   ============================================================ */

/* ========== WARM DARK (default :root) ========== */
:root {
  color-scheme: light dark;

  --bg-primary: #211c17;
  --bg-secondary: #2b251f;
  --bg-tertiary: #372f27;

  /* "glass" 클래스명은 유지하되 실제로는 포근한 솔리드 카드 */
  --glass-bg: #2b251f;
  --glass-border: rgba(240, 226, 206, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.35);

  --accent-primary: #7fc29b;   /* sage */
  --accent-secondary: #e0a06e; /* terracotta */
  --accent-tertiary: #e7a9a2;  /* soft rose */
  --accent-warm: #e8b04b;      /* honey */

  --gradient-primary: linear-gradient(135deg, #5fa986, #86cba8);
  --gradient-warm: linear-gradient(135deg, #e0a06e, #e7a9a2);
  --gradient-cool: linear-gradient(135deg, #7fc29b, #9bc3d1);
  --gradient-bg:
    radial-gradient(circle at 12% 8%, rgba(127, 194, 155, 0.10), transparent 45%),
    radial-gradient(circle at 88% 92%, rgba(224, 160, 110, 0.08), transparent 45%);

  --text-primary: #f0e9de;
  --text-secondary: #bdb1a1;
  --text-muted: #9a8e80; /* 대비 5.3:1 — 흐릿해서 안 읽히던 문제 보정 */

  --success: #7fc29b;
  --warning: #e8b04b;
  --danger: #e08a80;
  --info: #9bc3d1;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 6px 20px rgba(127, 194, 155, 0.28);

  --transition-fast: 0.18s ease;
  --transition-normal: 0.32s ease;
  --transition-slow: 0.5s ease;

  --font-main: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Gowun Batang', 'Noto Sans KR', serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========== WARM LIGHT ========== */
[data-theme="light"] {
  --bg-primary: #faf5ee;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f2e9dc;

  --glass-bg: #ffffff;
  --glass-border: rgba(120, 96, 66, 0.12);
  --glass-shadow: rgba(120, 96, 66, 0.10);

  --accent-primary: #4f8a6b;
  --accent-secondary: #c57c54;
  --accent-tertiary: #d98a84;
  --accent-warm: #d99a3c;

  --gradient-primary: linear-gradient(135deg, #4f8a6b, #6bae86);
  --gradient-warm: linear-gradient(135deg, #d98466, #e0a46e);
  --gradient-cool: linear-gradient(135deg, #4f8a6b, #7ba6b8);
  --gradient-bg:
    radial-gradient(circle at 10% 6%, rgba(79, 138, 107, 0.07), transparent 42%),
    radial-gradient(circle at 92% 94%, rgba(197, 124, 84, 0.06), transparent 42%);

  --text-primary: #362f28;
  --text-secondary: #6b6055;
  --text-muted: #7f7264; /* 기존 #a99c8c는 대비 2.5:1로 거의 안 보였음 → 4.6:1 */

  --success: #4f8a6b;
  --warning: #c98a2b;
  --danger: #cf6b60;
  --info: #6f97ab;

  --shadow-sm: 0 2px 10px rgba(120, 96, 66, 0.06);
  --shadow-md: 0 10px 28px rgba(120, 96, 66, 0.09);
  --shadow-lg: 0 22px 48px rgba(120, 96, 66, 0.13);
  --shadow-glow: 0 8px 22px rgba(79, 138, 107, 0.18);
}

/* ---- component tweaks that differ between themes ---- */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.glass-nav {
  background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--glass-border);
}

#app-header {
  background: linear-gradient(to bottom, var(--bg-primary) 62%, transparent);
}

/* Light-theme chat bubbles */
[data-theme="light"] .message.bot .message-content,
[data-theme="light"] .message.bot .message-bubble {
  background: #ffffff;
  border: 1px solid rgba(120, 96, 66, 0.14);
  box-shadow: 0 4px 14px rgba(120, 96, 66, 0.08);
}
[data-theme="light"] .message.user .message-content,
[data-theme="light"] .message.user .message-bubble {
  color: #ffffff;
}

/* ── 어두운 전체화면 오버레이의 글자색 ─────────────────────────────────
   전역 h·p 규칙이 라이트 테마에서 '어두운 글자색'을 강제해 어두운 오버레이
   (마음 응급처치·하루정리·수면 사운드·통화)에서 글씨가 아예 안 보였다.
   오버레이 안에서는 컨테이너에 지정한 밝은 색을 그대로 상속받는다. */
#calm-overlay h1, #calm-overlay h2, #calm-overlay h3, #calm-overlay p, #calm-overlay strong,
#night-overlay h1, #night-overlay h2, #night-overlay h3, #night-overlay p, #night-overlay strong,
#sleep-overlay h1, #sleep-overlay h2, #sleep-overlay h3, #sleep-overlay p, #sleep-overlay strong,
#call-overlay h1, #call-overlay h2, #call-overlay h3, #call-overlay p, #call-overlay strong {
  color: inherit;
}

/* 오버레이(하루정리·사고기록 위저드) placeholder — 배경색을 따라가게 */
#night-overlay textarea::placeholder { color: #f0ead9; opacity: 0.6; }
#tr-wizard textarea::placeholder,
#tr-wizard input::placeholder { color: var(--text-muted); opacity: 0.9; }

/* Light-theme inputs / textareas */
[data-theme="light"] textarea,
[data-theme="light"] .emotion-name {
  background: #faf5ee;
  color: var(--text-primary);
  border-color: var(--glass-border);
}
[data-theme="light"] .input-wrapper {
  background: #ffffff;
  border-color: var(--glass-border);
}

/* Light-theme chips */
[data-theme="light"] .chip {
  background: #faf5ee;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
[data-theme="light"] .chip.selected {
  background: color-mix(in srgb, var(--accent-primary) 14%, #ffffff);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Light-theme crisis modal */
[data-theme="light"] #crisis-modal .modal-content {
  background: #fff6f2;
  border-color: rgba(207, 107, 96, 0.25);
  box-shadow: 0 0 40px rgba(207, 107, 96, 0.1);
}
[data-theme="light"] .crisis-btn {
  background: rgba(207, 107, 96, 0.08);
  border: 1px solid rgba(207, 107, 96, 0.22);
  color: #a8483c;
}
[data-theme="light"] .crisis-btn:hover {
  background: rgba(207, 107, 96, 0.15);
}
[data-theme="light"] #crisis-modal h2 {
  color: #c0574a;
}

/* Light-theme secondary button */
[data-theme="light"] .btn-secondary {
  background: #ffffff;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}
[data-theme="light"] .btn-secondary:hover {
  background: #faf5ee;
}

[data-theme="light"] .close-btn:hover {
  background: rgba(120, 96, 66, 0.08);
  color: var(--text-primary);
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(120, 96, 66, 0.18);
}

@media (min-width: 481px) {
  [data-theme="light"] #app-container {
    border: 1px solid var(--glass-border);
    box-shadow: 0 24px 60px rgba(120, 96, 66, 0.16);
  }
}

/* Smooth theme transition */
body,
#app-container,
.glass-card,
.glass-nav,
#app-header,
.message-content,
.input-wrapper,
.chat-input-area,
.quick-replies,
.quick-reply-btn,
.chip,
.emotion-tag,
textarea,
.btn-secondary,
.nav-item,
.close-btn,
.stat-item,
.chart-container {
  transition: background-color 0.4s ease, color 0.4s ease,
              border-color 0.4s ease, box-shadow 0.4s ease;
}

/* ========== BASE / RESET ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  background-image: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.01em;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== APP CONTAINER ========== */
#app-container {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 481px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #app-container {
    height: 92vh;
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    overflow: hidden;
  }
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
h2 { font-size: 1.5rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.4rem; }
p { color: var(--text-secondary); }

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== CARDS ========== */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.glass-nav {
  border-top: 1px solid var(--glass-border);
}

/* ========== HEADER ========== */
#app-header {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  z-index: 50;
  padding: 1rem 1.25rem 1.4rem;
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  height: 44px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
}
.app-logo {
  font-size: 1.5rem;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 3px 6px rgba(127, 194, 155, 0.4));
}
.app-title {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.header-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* ========== TABS ========== */
.tab-content {
  display: none;
  flex: 1;
  height: 100%;
  width: 100%;
  /* px 대신 rem — 글자 크기 설정(108%·116%)에서도 바(탭·헤더)와 콘텐츠가 함께 커져 겹치지 않는다 */
  padding-top: 5.25rem;
  padding-bottom: calc(5.25rem + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn var(--transition-normal);
}
.tab-header {
  padding: 0 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
}
.tab-header h2 { display: flex; align-items: center; gap: 0.5rem; }
.tab-header .tab-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
#tab-record .tab-header {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

/* ========== CHAT ========== */
#tab-chat { padding-bottom: 0; position: relative; }
.chat-messages {
  flex: 1;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  padding-bottom: 8rem;
}
.message {
  display: flex;
  max-width: 85%;
  animation: messageSlideIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  opacity: 0;
}
.message.bot { align-self: flex-start; flex-direction: row; gap: 0.6rem; }
.bot-avatar,
.message.bot .message-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.message.bot .message-avatar > svg { display: block; width: 34px; height: 34px; }
.message.user .message-avatar { display: none; }
.message-content,
.message-bubble {
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.6;
  word-break: break-word;
}
.message-bubble p { margin: 0; color: inherit; }
.message-time {
  display: block;
  font-size: 0.68rem;
  margin-top: 0.35rem;
  opacity: 0.6;
}
.message.bot .message-content,
.message.bot .message-bubble {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}
.message.user { align-self: flex-end; }
.message.user .message-content,
.message.user .message-bubble {
  background: var(--gradient-primary);
  color: #fff;
  border-top-right-radius: 6px;
  box-shadow: var(--shadow-glow);
}

.typing-indicator { display: flex; gap: 4px; padding: 0.15rem 0.1rem; }
.typing-dot,
.typing-indicator span {
  width: 7px; height: 7px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1),
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2),
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* ========== QUICK REPLIES ========== */
.quick-replies {
  position: absolute;
  bottom: 84px;
  left: 0;
  width: 100%;
  padding: 0.5rem 1.25rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  background: linear-gradient(to top, var(--bg-primary) 78%, transparent);
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply-btn {
  white-space: nowrap;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  padding: 0.5rem 1.05rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.quick-reply-btn:hover, .quick-reply-btn:active {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
}

/* ========== CHAT INPUT ========== */
.chat-input-area {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  padding: 0.75rem 1.25rem calc(0.75rem + 4.65rem + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg-primary) 88%, transparent);
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}
#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem;
  resize: none;
  max-height: 120px;
  outline: none;
}
#chat-input::placeholder { color: var(--text-muted); }
.send-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  width: 42px; height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-left: 0.25rem;
}
.send-btn:not(:disabled) {
  color: #fff;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow);
}

/* ========== BUTTONS ========== */
.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  width: 100%;
}
.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-fast);
  width: 100%;
}
.btn-secondary:hover { filter: brightness(1.05); transform: translateY(-1px); }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.875rem; width: auto; }
.btn-text {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition-fast);
}
.close-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* ========== BOTTOM NAV ========== */
.bottom-nav {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  padding: 0.7rem 0 calc(0.7rem + var(--safe-bottom));
  z-index: 50;
}
.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  width: 62px;
}
.nav-item span:first-child {
  transition: transform var(--transition-fast);
  opacity: 0.7;
}
.nav-item.active { color: var(--accent-primary); }
.nav-item.active span:first-child {
  transform: translateY(-3px) scale(1.08);
  opacity: 1;
  filter: drop-shadow(0 3px 6px rgba(127, 194, 155, 0.35));
}
.nav-item::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: 26px; height: 4px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  transition: transform var(--transition-normal);
}
.nav-item.active::after { transform: translateX(-50%) scale(1); }

/* ========== THOUGHT RECORD ========== */
.record-list {
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.record-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  cursor: pointer;
  border-left: 4px solid var(--accent-secondary);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.record-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.record-card:active { transform: scale(0.99); }
.record-date { font-size: 0.75rem; color: var(--text-muted); }
.record-situation { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.emotion-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.emotion-tag {
  font-size: 0.75rem;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

/* ========== MODALS ========== */
.modal-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(33, 26, 20, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* 모달은 정의상 맨 위에 있어야 한다. 100 이던 시절에는
     설정 화면(#settings-overlay, z-index 900)이나 게임 화면(10001~) 안에서
     띄우면 그 뒤로 깔려서, 창은 열렸는데 안 보이니 '눌러도 반응이 없다'로 보였다.
     (예전에 global-install-modal 하나만 9999 로 때워 둔 흔적이 남아 있었다)
     UI 바텀시트(10090)와 운영자 코드창(10095)보다는 아래에 둔다. */
  z-index: 10080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.2s ease;
}
[data-theme="light"] .modal-overlay { background: rgba(120, 96, 66, 0.28); }
.modal-overlay.hidden { display: none; }
.modal-content {
  width: 100%;
  max-width: 400px;
  padding: 1.75rem;
  animation: scaleIn 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Crisis modal */
#crisis-modal .modal-content {
  background: #34211d;
  border-color: rgba(224, 138, 128, 0.3);
  box-shadow: 0 0 44px rgba(224, 138, 128, 0.2);
  text-align: center;
}
#crisis-modal h2 { color: #f0b4ac; margin-bottom: 1rem; }
.crisis-contacts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.crisis-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: rgba(224, 138, 128, 0.12);
  border: 1px solid rgba(224, 138, 128, 0.3);
  border-radius: var(--radius-md);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  transition: all var(--transition-fast);
}
.crisis-btn:hover { background: rgba(224, 138, 128, 0.22); transform: translateY(-2px); }
.crisis-icon { font-size: 1.25rem; }
.crisis-number { font-size: 1.1rem; letter-spacing: 1px; }
.crisis-disclaimer { font-size: 0.75rem; color: var(--text-muted); margin-top: 1rem; }

/* Disclaimer */
.disclaimer-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
  animation: float 3.5s infinite ease-in-out;
}
#disclaimer-modal h2 { text-align: center; font-size: 1.25rem; margin-bottom: 1rem; }
#disclaimer-modal ul {
  margin: 1rem 0 1.5rem 1.2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
#disclaimer-modal li { margin-bottom: 0.5rem; }

/* Forms */
.record-form-modal {
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.form-header {
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#record-form {
  padding: 1.35rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}
textarea:focus { border-color: var(--accent-primary); }

.emotion-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.emotion-name {
  width: 80px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  color: var(--text-primary);
  outline: none;
}
.emotion-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 5px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  outline: none;
}
.emotion-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(127, 194, 155, 0.5);
}
.emotion-value { width: 32px; text-align: right; font-size: 0.85rem; color: var(--text-secondary); }

.distortion-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.chip.selected {
  background: color-mix(in srgb, var(--accent-primary) 22%, transparent);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}
.form-actions { display: flex; gap: 1rem; margin-top: 1rem; align-items: stretch; }
/* 반반으로 나누면 '예약하고 결제하기'가 '결제하 / 기'로 꺾인다.
   취소는 글자 폭만, 실행 버튼이 남는 자리를 다 갖는다. */
/* .btn-primary/.btn-secondary 는 width:100% 라서 flex-basis:auto 가 100% 로 풀린다.
   여기서는 폭을 내용에 맡겨야 나눠 갖기가 제대로 된다. */
.form-actions > button { white-space: nowrap; width: auto; }
.form-actions > .btn-secondary { flex: 0 0 auto; padding-left: 1.2rem; padding-right: 1.2rem; }
.form-actions > .btn-primary { flex: 1 1 auto; min-width: 0; }

/* ========== DASHBOARD ========== */
.dashboard-grid { padding: 0 1.25rem; display: grid; gap: 1.25rem; }
.dash-card { padding: 1.25rem; }
.dash-card h3 {
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 1.2rem;
  font-family: var(--font-heading);
  font-weight: 700;
}
.chart-container {
  height: auto;
  min-height: 90px;
  width: 100%;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.stat-value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; font-weight: 500; }

/* ========== LEARN ========== */
.distortion-cards-grid {
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.85rem;
}
.distortion-card {
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.distortion-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-sm); border-color: var(--accent-primary); }
.dist-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.dist-title { font-size: 0.92rem; font-weight: 700; margin-bottom: 0.25rem; font-family: var(--font-heading); }
.dist-desc { font-size: 0.72rem; color: var(--text-muted); }

/* ========== 상담사 매칭 리디자인 (cc2) ========== */
.cc-chip {
  all: unset; box-sizing: border-box; flex-shrink: 0;
  font-size: 0.78rem; font-weight: 700; color: var(--text-secondary);
  background: var(--bg-secondary); border: 1.5px solid var(--glass-border);
  padding: 0.38rem 0.8rem; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: all var(--transition-fast);
}
.cc-chip.on {
  color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 13%, transparent);
  border-color: var(--accent-primary);
}
#cc-sort-pills::-webkit-scrollbar { display: none; }

.cc2 { padding: 1rem 1.05rem 0.8rem; border-radius: 18px; cursor: pointer; transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.cc2:active { transform: scale(0.995); }
.cc2-top { display: flex; gap: 0.8rem; align-items: flex-start; }
.cc2-ava { position: relative; flex-shrink: 0; width: 56px; height: 56px; }
.cc2-ava img, .cc2-ava svg { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid color-mix(in srgb, var(--accent-primary) 25%, transparent); }
.cc2-dot { position: absolute; right: 0; bottom: 2px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--bg-secondary); }
.cc2-dot.avail { background: #22b573; animation: cc2pulse 1.8s ease-out infinite; }
.cc2-dot.busy { background: #cf6b60; }
.cc2-dot.off { background: #a8a094; opacity: 0.7; }
@keyframes cc2pulse { 0% { box-shadow: 0 0 0 0 rgba(34,181,115,0.4); } 70% { box-shadow: 0 0 0 7px rgba(34,181,115,0); } 100% { box-shadow: 0 0 0 0 rgba(34,181,115,0); } }
.cc2-info { flex: 1; min-width: 0; }
.cc2-name { font-size: 1rem; font-weight: 800; color: var(--text-primary); font-family: var(--font-heading); }
.cc2-new { background: #e8590c22; color: #e8590c; font-size: 0.62rem; font-weight: 800; padding: 0.12rem 0.42rem; border-radius: 999px; vertical-align: middle; }
.cc2-hosp { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc2-meta { display: flex; flex-wrap: wrap; gap: 0.55rem; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.3rem; }
.cc2-meta b { color: var(--text-primary); }
.cc2-st.avail { color: #22b573; font-weight: 700; }
.cc2-st.busy { color: #cf6b60; font-weight: 700; }
.cc2-st.off { opacity: 0.75; }
.cc2-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.45rem; }
.cc2-tag { font-size: 0.68rem; font-weight: 700; color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 10%, transparent); padding: 0.16rem 0.5rem; border-radius: 999px; }
.cc2-duo { display: flex; gap: 0.45rem; margin-top: 0.7rem; }
.cc2-duo > * { flex: 1; text-align: center; border-radius: 11px; padding: 0.42rem 0.3rem; box-sizing: border-box; }
.cc2-duo b { display: block; font-size: 0.8rem; }
.cc2-duo span { font-size: 0.62rem; }
.cc2-book { border: none; background: var(--gradient-primary); color: #fff; cursor: pointer; box-shadow: var(--shadow-sm); font-family: var(--font-main); }
.cc2-book:active { transform: scale(0.98); }
.cc2-live { border: 1.5px solid color-mix(in srgb, var(--accent-secondary) 45%, transparent); background: color-mix(in srgb, var(--accent-secondary) 13%, var(--bg-tertiary)); color: var(--accent-secondary); cursor: pointer; font-family: var(--font-main); }
.cc2-live span { color: var(--text-muted); }
.cc2-live.is-busy { border-color: color-mix(in srgb, #cf6b60 35%, transparent); background: color-mix(in srgb, #cf6b60 9%, var(--bg-tertiary)); color: #cf6b60; cursor: default; }
.cc2-live.is-off { border: 1px dashed var(--glass-border); background: var(--bg-tertiary); color: var(--text-muted); opacity: 0.7; cursor: default; }
.cc2-links { display: flex; align-items: center; justify-content: center; gap: 0.9rem; margin-top: 0.35rem; }
.cc2-links button { all: unset; font-size: 0.74rem; font-weight: 600; color: var(--text-muted); cursor: pointer; padding: 0.3rem 0.2rem; }
.cc2-links i { width: 1px; height: 10px; background: var(--glass-border); }

/* ========== 인지왜곡 학습 리뉴얼 ========== */
.learn-hero {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 0 1.25rem 1.1rem; padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-primary) 14%, var(--bg-secondary)), var(--bg-secondary));
  border: 1.5px solid color-mix(in srgb, var(--accent-primary) 28%, transparent);
  box-shadow: var(--shadow-sm);
}
.learn-hero__bubble strong { display: block; font-size: 0.95rem; color: var(--accent-primary); margin-bottom: 0.25rem; font-family: var(--font-heading); }
.learn-hero__bubble p { margin: 0; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.55; }

.distortion-card { position: relative; overflow: hidden; padding: 1.1rem 0.9rem 0.95rem; }
.distortion-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--dc-color, var(--accent-primary));
}
.dc-num {
  position: absolute; top: 0.55rem; right: 0.7rem;
  font-size: 0.66rem; font-weight: 800; color: var(--text-muted); opacity: 0.6;
}
.dc-icon-chip {
  width: 46px; height: 46px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.dc-title { font-size: 0.94rem; font-weight: 800; margin: 0.55rem 0 0.2rem; color: var(--text-primary); font-family: var(--font-heading); }
.dc-brief { font-size: 0.74rem; color: var(--text-muted); margin: 0 0 0.5rem; line-height: 1.4; }
.dc-more { font-size: 0.72rem; font-weight: 800; }

/* 우렁 선생님 처방 (상세 모달) */
.detail-woorung { display: flex; align-items: flex-start; gap: 0.6rem; margin-top: 1rem; }
.detail-woorung__bubble {
  flex: 1; background: var(--bg-tertiary); border: 1px solid var(--glass-border);
  border-radius: 4px 16px 16px 16px; padding: 0.8rem 0.95rem;
}
.detail-woorung__bubble strong { display: block; font-size: 0.82rem; margin-bottom: 0.3rem; }
.detail-woorung__bubble p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }

/* 퀴즈 */
.quiz-section { padding: 0 1.25rem 1.5rem; margin-top: 0.5rem; }
.quiz-card { padding: 1.3rem; }
.quiz-intro { text-align: center; }
.quiz-intro__title { margin: 0.6rem 0 0.3rem; font-size: 1.15rem; color: var(--text-primary); font-family: var(--font-heading); }
.quiz-intro__desc { margin: 0 0 0.9rem; font-size: 0.84rem; color: var(--text-secondary); line-height: 1.6; }
.quiz-intro__best { margin: 0 0 0.8rem; font-size: 0.8rem; font-weight: 700; color: var(--accent-warm); }

.quiz-progress-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.quiz-progress-label { font-size: 0.78rem; font-weight: 800; color: var(--text-muted); }
.quiz-score-label { font-size: 0.82rem; font-weight: 800; color: var(--accent-warm); }
.quiz-progress-bar { height: 7px; border-radius: 99px; background: var(--bg-tertiary); overflow: hidden; margin-bottom: 0.9rem; }
.quiz-progress-bar > div { height: 100%; border-radius: 99px; background: var(--gradient-primary); transition: width 0.4s ease; }

.quiz-scene { display: flex; align-items: flex-start; gap: 0.55rem; margin-bottom: 0.9rem; }
.quiz-question-box {
  flex: 1; background: var(--bg-tertiary); border: 1px solid var(--glass-border);
  border-radius: 4px 16px 16px 16px; padding: 0.85rem 1rem; text-align: left;
}
.quiz-q-text { margin: 0 0 0.4rem; font-size: 0.92rem; font-weight: 600; color: var(--text-primary); line-height: 1.55; }
.quiz-q-sub { margin: 0; font-size: 0.76rem; color: var(--text-muted); }

.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.quiz-option {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.7rem 0.8rem; border-radius: 12px;
  background: var(--bg-tertiary); border: 1.5px solid var(--glass-border);
  color: var(--text-primary); font-size: 0.84rem; font-weight: 700;
  cursor: pointer; text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  font-family: var(--font-main);
}
.quiz-option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent-primary); }
.quiz-option:disabled { cursor: default; opacity: 0.75; }
.quiz-option.correct {
  background: color-mix(in srgb, var(--success) 16%, var(--bg-tertiary));
  border-color: var(--success); color: var(--success); opacity: 1;
}
.quiz-option.incorrect {
  background: color-mix(in srgb, var(--danger) 14%, var(--bg-tertiary));
  border-color: var(--danger); color: var(--danger); opacity: 1;
}
.qo-ico { display: inline-flex; flex-shrink: 0; }

.quiz-feedback { margin-top: 0.9rem; }
.quiz-feedback__inner {
  display: flex; align-items: center; gap: 0.6rem; text-align: left;
  border-radius: 14px; padding: 0.8rem 0.95rem;
}
.quiz-feedback__inner.is-correct { background: color-mix(in srgb, var(--success) 12%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); }
.quiz-feedback__inner.is-wrong { background: color-mix(in srgb, var(--accent-warm) 12%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, var(--accent-warm) 35%, transparent); }
.quiz-feedback__inner strong { display: block; font-size: 0.88rem; color: var(--text-primary); margin-bottom: 0.2rem; }
.quiz-feedback__inner p { margin: 0; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }

.quiz-results { text-align: center; }
.quiz-results__title { margin: 0.6rem 0 0.2rem; font-size: 1.2rem; color: var(--text-primary); font-family: var(--font-heading); }
.quiz-score-big { font-size: 2.1rem; font-weight: 800; color: var(--accent-primary); }
.quiz-score-big span { font-size: 1.1rem; color: var(--text-muted); font-weight: 700; }
.quiz-msg { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; margin: 0 0 1rem; }

/* ========== EMPTY STATES ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}
.empty-state.hidden { display: none; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.55; }
.empty-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; }

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes messageSlideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.55; }
  100% { opacity: 1; }
}
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ============================================================
   ICONS & ILLUSTRATIONS (커스텀 SVG 시스템)
   ============================================================ */
[data-icon] > svg, [data-art] > svg { display: block; }
.h-ico, .lbl-ico, .nav-ico, .crisis-icon, .banner-ico,
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* 인라인 헤더/라벨 아이콘 정렬 */
.tab-header h2, .card-head, #record-form label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.h-ico { color: var(--accent-primary); flex-shrink: 0; }
.lbl-ico { color: var(--accent-secondary); flex-shrink: 0; }
#crisis-modal h2, #disclaimer-modal h2 { display: block; }

/* 앱 로고 (마스코트) */
.app-logo {
  display: inline-flex;
  align-items: center;
  animation: float 5s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(120, 96, 66, 0.18));
}

/* 로고 위 알림 배지 — 상담사에게 온 게 있을 때만 붙는다 (js/prolink.js) */
.pro-badge {
  position: absolute;
  top: -4px; right: -7px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e0524d;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 2px 5px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  animation: none;
}
.pro-badge.ringing { animation: proBadgeRing 0.9s ease-in-out infinite; }
@keyframes proBadgeRing {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.22); }
}
@media (prefers-reduced-motion: reduce) { .pro-badge.ringing { animation: none; } }

/* 헤더 버튼 아이콘 정렬 */
.header-btn { display: inline-flex; align-items: center; justify-content: center; }
.header-btn--pro {
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--glass-border);
  padding: 0.28rem 0.6rem !important;
  margin-right: 0.35rem;
  border-radius: var(--radius-full);
}
.header-btn--pro > span:last-child { line-height: 1; }

/* 하단 네비 아이콘 */
.nav-ico { color: inherit; }

/* 모달 상단 아이콘 뱃지 */
.modal-icon {
  width: 76px; height: 76px;
  margin: 0 auto 1rem;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  animation: float 3.5s infinite ease-in-out;
}
.modal-icon--crisis { background: rgba(224, 138, 128, 0.16); color: #f0b4ac; }
[data-theme="light"] .modal-icon--crisis { background: rgba(207, 107, 96, 0.12); color: #c0574a; }
.modal-icon--pro { background: color-mix(in srgb, var(--accent-warm) 18%, transparent); color: var(--accent-warm); }
.disclaimer-icon { display: flex; justify-content: center; }
.disclaimer-icon > svg { filter: drop-shadow(0 6px 14px rgba(120, 96, 66, 0.18)); }

/* 위기 연락처 아이콘 */
.crisis-icon { color: inherit; }

/* 빈 상태 일러스트 */
.empty-icon { opacity: 1; display: flex; justify-content: center; }
.empty-icon > svg { opacity: 0.9; }

/* PWA 배너 아이콘 */
.banner-ico {
  width: 48px; height: 48px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  color: var(--accent-primary);
}

/* ============================================================
   HOME — 섹션 기반 레이아웃
   구성: 인사 → 오늘(체크인·미션) → 상담 시작 → 마음 도구 → 제휴
   ============================================================ */

/* 섹션 제목 줄 */
.home-sec {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; margin: 1.3rem 1.25rem 0.6rem;
}
.home-sec h3 {
  margin: 0; font-size: 0.98rem; font-weight: 800;
  color: var(--text-primary); font-family: var(--font-heading);
  display: flex; align-items: center; gap: 0.4rem;
}
.home-sec__sub { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); }

/* 홈 공용 카드 */
.home-card { margin: 0 1.25rem 0.7rem; padding: 0.9rem 1rem; }
.home-card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.6rem;
}
.home-card__t { margin: 0 0 0.6rem; font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.home-card__head .home-card__t { margin: 0; }
.home-card__hint { font-size: 0.7rem; color: var(--text-muted); }

/* 원탭 기분 체크인 */
.home-mood { display: flex; justify-content: space-between; gap: 0.3rem; }
.home-mood__btn {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0;
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.05rem;
  padding: 0.35rem 0 0.3rem; border-radius: 12px;
  cursor: pointer; font-family: inherit;
  transition: background var(--transition-fast);
}
.home-mood__btn > span:first-child { line-height: 0; }
.home-mood__lbl { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); }

/* 상담 시작하기 — AI / 전문 상담사 2열 */
.home-start { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin: 0 1.25rem; }
.home-start__card {
  appearance: none; text-align: left; font-family: inherit;
  display: flex; flex-direction: column; gap: 0.45rem;
  padding: 1rem 0.9rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.home-start__card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.home-start__card--ai {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-primary) 12%, var(--bg-secondary)), var(--bg-secondary));
  border-color: color-mix(in srgb, var(--accent-primary) 30%, transparent);
}
.home-start__card--human {
  background: linear-gradient(135deg, color-mix(in srgb, #3b82f6 9%, var(--bg-secondary)), var(--bg-secondary));
  border-color: rgba(138, 180, 248, 0.3);
}
.home-start__ico {
  width: 42px; height: 42px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--accent-primary) 14%, transparent);
  color: var(--accent-primary);
}
/* 다크가 기본 테마 — 파랑은 밝은 톤으로 (진한 #2563eb 는 어두운 배경에서 대비 3.3:1) */
.home-start__card--human .home-start__ico { background: rgba(138, 180, 248, 0.16); color: #8ab4f8; }
.home-start__t {
  font-size: 0.95rem; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-heading);
}
.home-start__d { font-size: 0.74rem; color: var(--text-muted); line-height: 1.4; }
.home-start__go {
  margin-top: auto; font-size: 0.76rem; font-weight: 700;
  color: var(--accent-primary);
  display: inline-flex; align-items: center; gap: 0.2rem;
}
.home-start__card--human .home-start__go { color: #8ab4f8; }

/* 라이트 테마에서는 진한 파랑이 대비가 좋다 */
[data-theme="light"] .home-start__card--human { border-color: rgba(37, 99, 235, 0.28); }
[data-theme="light"] .home-start__card--human .home-start__ico { background: rgba(37, 99, 235, 0.13); color: #2563eb; }
[data-theme="light"] .home-start__card--human .home-start__go { color: #2563eb; }

/* 내 마음 도구 — 2열 가로형 */
.home-tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin: 0 1.25rem 0.4rem; }
.home-tool {
  display: flex; align-items: center; gap: 0.7rem;
  text-align: left;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  font-family: inherit;
}
.home-tool:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.home-tool__ico {
  width: 38px; height: 38px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  color: var(--accent-primary);
}
.home-tool__txt { display: flex; flex-direction: column; min-width: 0; }
.home-tool__t,
.home-tool__d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-tool__t { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }
.home-tool__d { font-size: 0.68rem; color: var(--text-muted); }

/* 제휴 콘텐츠 가로 스크롤 */
.home-ads {
  display: flex; gap: 0.8rem; overflow-x: auto;
  padding: 0 1.25rem 1rem;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.home-ads::-webkit-scrollbar { display: none; }
.home-ad { min-width: 240px; scroll-snap-align: start; cursor: pointer; overflow: hidden; }

/* 제휴 카드 일러스트 */
.ad-art { line-height: 0; }
.ad-art > svg { display: block; width: 100%; height: 120px; }

/* 상담사 아바타 */
.counselor-avatar {
  flex-shrink: 0;
  width: 76px; height: 76px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.counselor-avatar--lg { width: 96px; height: 96px; }
.counselor-avatar > svg { display: block; width: 100%; height: 100%; }

/* 상담사 카드 (레이아웃 재정비) */
.counselor-card {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}
.cc-top { display: flex; gap: 0.9rem; }
.cc-info { flex: 1; min-width: 0; }
.cc-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.cc-name-row h3 {
  margin: 0;
  font-size: 1.08rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 15%, transparent);
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.cc-hospital {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.3rem 0 0;
}
.cc-hospital > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  margin: 0.45rem 0;
}
.cc-rating .cc-reviews { color: var(--text-muted); font-size: 0.8rem; font-weight: 400; }
.cc-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.cc-tag {
  font-size: 0.72rem;
  color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  padding: 0.24rem 0.6rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.cc-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--glass-border);
}
.cc-price { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cc-price > span { font-size: 0.72rem; color: var(--text-muted); }
.cc-price > strong { font-size: 1.05rem; white-space: nowrap; }
.cc-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.cc-btn {
  width: auto;
  white-space: nowrap;
  padding: 0.55rem 1.15rem;
  font-size: 0.9rem;
}
.meta-line { display: flex; align-items: center; gap: 5px; }
.meta-line > svg { flex-shrink: 0; color: var(--text-muted); }
.star-row > svg { display: block; }

/* 학습 카드 내부 텍스트 */
.dc-title { font-family: var(--font-heading); font-size: 0.95rem; font-weight: 700; margin: 0 0 2px; color: var(--text-primary); }
.dc-subtitle { font-size: 0.66rem; color: var(--text-muted); margin: 0 0 6px; letter-spacing: 0.02em; }
.dc-brief { font-size: 0.76rem; color: var(--text-secondary); margin: 0; line-height: 1.4; }

/* 대시보드 왜곡 막대 차트 */
.bar-chart-container { display: flex; flex-direction: column; gap: 0.85rem; width: 100%; padding: 0.25rem 0.5rem; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 26px; align-items: center; gap: 0.75rem; }
.bar-label { font-size: 0.82rem; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.bar-track { height: 14px; background: color-mix(in srgb, var(--bg-tertiary) 60%, transparent); border: 1px solid var(--glass-border); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); }
.bar-fill { height: 100%; border-radius: 999px; background-image: linear-gradient(90deg, rgba(255,255,255,0.2) 0%, transparent 100%); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.bar-value { font-size: 0.85rem; font-weight: 700; color: var(--accent-primary); text-align: right; }

/* 사고 기록 카드 내부 */
.record-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.2rem; }
.record-body { display: flex; flex-direction: column; gap: 0.55rem; }
.record-section strong { font-size: 0.72rem; color: var(--accent-primary); font-weight: 700; }
.record-text { font-size: 0.88rem; color: var(--text-secondary); margin: 2px 0 0; line-height: 1.5; }
.record-text.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.emotion-tag.intensity-high { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.emotion-tag.intensity-med { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.emotion-tag.intensity-low { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.distortion-chip.small { font-size: 0.72rem; padding: 0.2rem 0.55rem; background: var(--bg-tertiary); border: 1px solid var(--glass-border); border-radius: 999px; color: var(--text-secondary); }

/* JS로 그려지는 아이콘 래퍼 정렬 (학습/기록 탭) */
.qo-ico, .chip-ico {
  display: inline-flex;
  align-items: center;
  margin-right: 5px;
  vertical-align: middle;
}
.distortion-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dc-icon { display: flex; justify-content: center; margin-bottom: 0.4rem; }
.detail-emoji { display: flex; justify-content: center; margin-bottom: 0.5rem; }
.btn-delete-record, .btn-remove-emotion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ========== UTILITIES ========== */
.hidden { display: none !important; }

/* ========== PRO MODE (warm honey accent) ========== */
body.pro-mode-active {
  --accent-primary: #e8b04b;
  --accent-secondary: #d99a3c;
  --gradient-primary: linear-gradient(135deg, #e8b04b, #d99a3c);
  --shadow-glow: 0 6px 20px rgba(232, 176, 75, 0.32);
}
[data-theme="light"] body.pro-mode-active {
  --accent-primary: #c98a2b;
  --accent-secondary: #b0741f;
  --gradient-primary: linear-gradient(135deg, #d99a3c, #c98a2b);
  --shadow-glow: 0 6px 20px rgba(201, 138, 43, 0.22);
}
body.pro-mode-active .app-logo { filter: drop-shadow(0 3px 6px rgba(232, 176, 75, 0.5)); }
body.pro-mode-active #btn-pro {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent !important;
  box-shadow: var(--shadow-glow);
}

/* ========== VOICE RECORDING PULSE ========== */
.mic-btn.recording {
  color: var(--danger) !important;
  background: rgba(224, 138, 128, 0.15) !important;
  animation: mic-pulse 1.2s infinite ease-in-out;
}
@keyframes mic-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224, 138, 128, 0.5); }
  50% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(224, 138, 128, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224, 138, 128, 0); }
}

/* ============================================================
   삼성 인터넷 등 브라우저의 '강제 다크(야간) 모드' 방어.
   앱이 자체 라이트/다크 테마를 가지고 있음을 명시해,
   브라우저가 색을 멋대로 반전시키지 않게 한다.
   ============================================================ */
:root, html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"], [data-theme="dark"] { color-scheme: dark; }

/* 헤더 없는 탭(홈·챗봇·상담사매칭·대시보드): 로고 바와 그 여백까지 제거 */
body.header-hidden #app-header { display: none; }
body.header-hidden .tab-content { padding-top: 10px; }

/* 키보드가 올라온 동안(입력 중): 하단바 숨기고 그 여백까지 걷어내
   입력창이 키보드 바로 위에 붙게 한다 */
body.kb-open #bottom-nav { display: none; }
body.kb-open .tab-content { padding-bottom: 8px; }
/* 입력창의 하단 패딩에 박혀 있던 탭바 몫(74px)도 함께 제거 —
   키보드 위에 빈 공간이 뜨던 문제의 원인 */
body.kb-open .chat-input-area { padding-bottom: calc(0.75rem + var(--safe-bottom)); }
body.kb-open .chat-messages { padding-bottom: 4.4rem; }

/* ============================================================
   반응형 — 작은 폰(≤380px, ≤340px)에서도 깨지지 않게
   ============================================================ */
@media (max-width: 380px) {
  .tab-header h2 { font-size: 1.15rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .home-tools { gap: 0.5rem; }
  .home-tool { padding: 0.7rem 0.6rem; gap: 0.55rem; }
  .home-tool__ico { width: 34px; height: 34px; }
  .home-tool__t { font-size: 0.8rem; }
  .home-start { gap: 0.5rem; }
  .home-start__card { padding: 0.85rem 0.7rem; }
  #persona-bar { gap: 0.4rem; padding: 0.4rem 0.6rem; }
  #persona-bar .btn-secondary { font-size: 0.68rem !important; padding: 0.3rem 0.5rem !important; }
  .message-bubble { max-width: 82%; }
  #wallet-card-body [style*="grid-template-columns"] { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 340px) {
  #persona-bar-tagline { display: none; }
  .tab-header h2 { font-size: 1.05rem; }
  .message-bubble { max-width: 88%; }
  .form-actions { flex-wrap: wrap; }
}
/* 큰 폰(≥430px): 콘텐츠 폭 유지하며 여백만 살짝 */
@media (min-width: 430px) {
  .tab-content { padding-left: 4px; padding-right: 4px; }
}

/* ============================================================
   큰 글꼴 방어 — 갤럭시 '글자 크게' 설정에서도 텍스트가 잘리지 않게
   ============================================================ */
/* 상담사 카드 하단: 가격은 절대 잘리지 않고, 공간이 부족하면 줄바꿈 */
.cc-bottom { flex-wrap: wrap; }
.cc-price { flex-shrink: 0; }
.cc-price > strong { white-space: nowrap; overflow: visible; }
.cc-actions { flex-wrap: wrap; justify-content: flex-end; }

/* 버튼 글자는 넘치면 줄바꿈 (한 단어 잘림 방지) */
.btn-primary, .btn-secondary { line-height: 1.3; }

/* 프로필 바 도구 줄: 큰 글씨에서 자연스럽게 줄바꿈 */
#persona-bar > div:last-child { flex-wrap: wrap; row-gap: 0.3rem; }

/* 하단 내비 라벨: 잘리는 대신 축소 */
.bottom-nav .nav-item span:last-child { font-size: clamp(0.55rem, 2.6vw, 0.72rem); white-space: nowrap; }

/* 상담사 카드 버튼: 3개(프로필·채팅·통화) 한 줄 + 예약하기 전체 폭 */
.cc-actions { width: 100%; display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.cc-actions .cc-btn { width: 100%; box-sizing: border-box; text-align: center; padding: 0.5rem 0.2rem; font-size: 0.8rem; white-space: nowrap; }
.cc-actions .btn-primary { grid-column: 1 / -1; padding: 0.6rem 0.2rem; font-size: 0.9rem; }
.cc-bottom { flex-direction: column; align-items: stretch; gap: 0.6rem; }
.cc-price { flex-direction: row !important; justify-content: space-between; align-items: baseline; }

/* ============================================================
   우렁이 세계 — 게임 컨테이너
   ============================================================ */
#game-stage { min-height: 280px; }
.game-view-tip { font-size: 0.74rem; color: var(--text-muted); margin: 0 0 0.8rem; line-height: 1.5; }
#game-nav {
  display: flex; gap: 0.2rem;
  margin-top: 0.85rem; padding-top: 0.5rem;
  border-top: 1px solid var(--glass-border);
}
#game-nav button {
  appearance: none; -webkit-appearance: none; background: transparent; border: 0;
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  padding: 0.4rem 0 0.45rem; border-radius: 12px; cursor: pointer; font-family: inherit;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
#game-nav button:active { transform: scale(0.94); }
.game-nav-emoji { font-size: 1.15rem; line-height: 1.2; filter: grayscale(0.65); opacity: 0.75; transition: filter var(--transition-fast), opacity var(--transition-fast); }
.game-nav-label { font-size: 0.62rem; font-weight: 800; color: var(--text-muted); }
#game-nav button.active { background: color-mix(in srgb, var(--accent-primary) 13%, transparent); }
#game-nav button.active .game-nav-emoji { filter: none; opacity: 1; }
#game-nav button.active .game-nav-label { color: var(--accent-primary); }

/* 사고기록 카드 리디자인 */
.record-card {
  border-left: 4px solid var(--accent-primary);
  border-radius: 16px;
  padding: 1rem 1.05rem;
}
.record-card .record-header { margin-bottom: 0.55rem; }
.record-card .record-date { font-size: 0.7rem; color: var(--text-muted); }
.record-card .record-section { margin-bottom: 0.5rem; }
.record-card .record-section strong {
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent-primary);
  margin-bottom: 0.15rem;
}
.record-card .record-text { margin: 0; font-size: 0.86rem; line-height: 1.6; color: var(--text-primary); }
.record-card .record-text.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.record-card .record-emotions, .record-card .record-distortions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.55rem; }
.record-card .distortion-chip.small { font-size: 0.68rem; padding: 0.2rem 0.55rem; border-radius: 999px; }
.record-card .btn-expand-record {
  margin-top: 0.65rem;
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0.4rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.record-card .record-detail { margin-top: 0.55rem; padding-top: 0.55rem; border-top: 1px dashed var(--glass-border); }
.record-card .record-detail .record-section strong { color: var(--accent-secondary); }

/* 게임 카드 가로 넘침 방지 — nowrap 내용이 카드 폭을 밀어올리지 못하게 */
.dashboard-grid > * { min-width: 0; max-width: 100%; }
.dash-card, #game-stage, .game-view, #game-hud, #mail-body { min-width: 0; }
.dash-card { overflow-x: hidden; }

/* 게임 카드 리듬 */
#game-hud { padding-bottom: 0.6rem; border-bottom: 1px solid var(--glass-border); }
#game-stage { padding-top: 0.7rem; }
#game-nav { margin-top: 0.7rem; }
#game-sheet .home-mood__btn { padding: 0.3rem 0 0.25rem; }

/* ============================================================
   마이탭 리디자인 — 프로필 헤더 + 재화 카드 + 메뉴 리스트
   ============================================================ */
.my-hero {
  display: flex; align-items: center; gap: 0.85rem;
  margin: 1rem 1.25rem 0.9rem; padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-primary) 14%, var(--bg-secondary)), var(--bg-secondary));
  border: 1px solid color-mix(in srgb, var(--accent-primary) 25%, transparent);
  box-shadow: var(--shadow-sm);
}
.my-hero__ava { line-height: 0; flex-shrink: 0; }
.my-hero__txt { flex: 1 1 0%; min-width: 0; }
.my-hero__txt strong { display: block; font-size: 1.05rem; font-weight: 800; color: var(--text-primary); font-family: var(--font-heading); }
.my-hero__txt span { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.15rem; }
.my-hero__edit {
  all: unset; flex-shrink: 0; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: var(--text-muted);
  background: var(--bg-tertiary); border: 1px solid var(--glass-border);
}

.my-money { display: grid; grid-template-columns: 1fr; gap: 0.6rem; margin: 0 1.25rem 0.4rem; }
@media (min-width: 520px) { .my-money { grid-template-columns: 1fr 1fr; } }
.my-money__card {
  background: var(--bg-secondary); border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg); padding: 0.9rem 1rem; box-shadow: var(--shadow-sm);
}
.my-money__t { margin: 0 0 0.55rem; font-size: 0.85rem; font-weight: 800; color: var(--text-primary); }
.my-money__note { margin: 0.55rem 0 0; font-size: 0.68rem; color: var(--text-muted); line-height: 1.5; }

.my-sec { margin: 1.3rem 1.25rem 0.45rem; font-size: 0.72rem; font-weight: 800; color: var(--text-muted); letter-spacing: 0.04em; }
.my-group {
  margin: 0 1.25rem; background: var(--bg-secondary);
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.my-row {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--glass-border);
  transition: background var(--transition-fast);
}
.my-group > *:last-child { border-bottom: 0; }
.my-row:active { background: var(--bg-tertiary); }
.my-row--static { cursor: default; }
.my-row__ico { flex-shrink: 0; font-size: 1.15rem; line-height: 1; width: 26px; text-align: center; }
.my-row__txt { flex: 1 1 0%; min-width: 0; }
.my-row__txt b { display: block; font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.my-row__txt > span { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; line-height: 1.5; }
.my-row__txt > span b { display: inline; font-size: inherit; color: var(--text-secondary); }
.my-row__go { flex-shrink: 0; color: var(--text-muted); font-size: 1.1rem; font-weight: 700; }
.my-row__btn {
  all: unset; flex-shrink: 0; cursor: pointer;
  font-size: 0.72rem; font-weight: 700; color: var(--accent-primary);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 35%, transparent);
  padding: 0.25rem 0.6rem; border-radius: 999px;
}
.my-row__body { padding: 0 1rem 0.9rem; }
.my-row__body:empty { display: none; }
.my-row--privacy .my-row__txt > span { color: var(--text-secondary); }

/* 홈 상단 로고 */
.home-logo { display: flex; align-items: center; gap: 0.45rem; margin: 0.9rem 1.25rem 0.2rem; }
.home-logo__mark { line-height: 0; flex-shrink: 0; }
.home-logo__t { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); font-family: var(--font-heading); letter-spacing: -0.02em; }

/* 대시보드 톤 통일 */

.my-badge {
  display: inline-block; font-size: 0.62rem; font-weight: 800; color: #c9a227;
  border: 1px solid color-mix(in srgb, #c9a227 45%, transparent);
  padding: 0.05rem 0.38rem; border-radius: 999px; vertical-align: 1px; margin-left: 0.2rem;
}
.dashboard-grid { padding: 0 1.25rem 1rem; }
.dashboard-grid > .dash-card { border-radius: var(--radius-lg); }
#tab-dashboard .my-group { box-shadow: var(--shadow-sm); }

/* 우렁이 배회 — 활발한 포즈일 때만 방 안을 오간다 */
.wr-wander { will-change: transform; }
/* 걷다가 오래 쉬는 리듬 — 전체의 1/3만 이동하고 나머지는 제자리 */
@keyframes wr-stroll {
  0%,  18%  { transform: translateX(0) scaleX(1); }
  34%       { transform: translateX(var(--wr-far, 60px)) scaleX(1); }
  36%, 62%  { transform: translateX(var(--wr-far, 60px)) scaleX(-1); }
  78%       { transform: translateX(0) scaleX(-1); }
  80%, 100% { transform: translateX(0) scaleX(1); }
}
@keyframes wr-bob { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-3px) } }
@media (prefers-reduced-motion: reduce) { .wr-wander { animation: none !important; } }

/* 게임 아이콘 정렬 — 라인 아이콘을 텍스트와 같은 줄에 맞춘다 */
#tab-dashboard button svg { vertical-align: -3px; }
.game-nav-emoji { line-height: 0; filter: none; opacity: 0.55; color: var(--text-muted); }
#game-nav button.active .game-nav-emoji { opacity: 1; color: var(--accent-primary); }
#game-hud svg, #room-body svg.wr-ico { vertical-align: -2px; }

/* 마이탭 수축 방지 — .tab-content 가 flex column 이라 자식이 찌그러진다 */
.my-hero, .my-money, .my-group, .my-sec, .home-logo, .dash-lede { flex-shrink: 0; }
.my-group { display: flow-root; }

/* 좁은 폭에서 지갑 충전 버튼이 뭉치지 않게 */
.my-money__card #wallet-card-body [style*="grid-template-columns"] { grid-template-columns: repeat(3, 1fr) !important; gap: 0.3rem !important; }
.my-money__card #wallet-card-body .btn-secondary { font-size: 0.68rem !important; padding: 0.4rem 0.15rem !important; }

/* 작은 아이콘 가독성 — 12~16px 에서는 선을 굵게 */




/* 캐릭터 접지 그림자 — 래퍼 안에 있어 배회할 때 함께 이동한다 */
.wr-stand { position: relative; line-height: 0; }
.wr-stand::after {
  content: ""; position: absolute; left: 50%; bottom: 6%;
  width: 60%; height: 10px; transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.10) 45%, rgba(0,0,0,0) 72%);
  pointer-events: none; z-index: -1;
}
/* 걷는 동안 살짝 통통 — 그림자는 함께 눌린다 */
.wr-wander .wr-stand { animation: wr-bob 1.3s ease-in-out infinite; }

/* 퀘스트 화면 — 제목/보상 배지 */
.q-title { display: flex; align-items: center; gap: 0.35rem; font-size: 0.92rem; font-weight: 800; color: var(--text-primary); }
.q-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.6rem; font-size: 0.86rem; font-weight: 700; color: var(--text-primary); }
.q-reward {
  display: inline-flex; align-items: center; gap: 0.2rem;
  font-size: 0.68rem; font-weight: 800; color: #6f97ab;
  background: color-mix(in srgb, #6f97ab 12%, transparent);
  border: 1px solid color-mix(in srgb, #6f97ab 28%, transparent);
  padding: 0.12rem 0.5rem; border-radius: 999px; white-space: nowrap;
}

#care-footprint svg { vertical-align: -2px; }

/* 마이탭 아이콘 — 라인 아이콘을 텍스트 톤에 맞춘다 */
.my-row__ico { display: inline-flex; align-items: center; justify-content: center; color: var(--accent-primary); line-height: 0; }

.my-money__t { display: flex; align-items: center; gap: 0.35rem; }

.my-row--privacy .my-row__ico { color: var(--text-muted); }

/* ============================================================
   홈 리디자인 — 상단 헤더 · 섹션 리듬
   ============================================================ */
.home-top {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0.9rem 1.25rem 0.5rem; flex-shrink: 0;
}
.home-logo__mark { line-height: 0; flex-shrink: 0; }
.home-logo__t {
  font-size: 1.18rem; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-heading); letter-spacing: -0.02em;
}
.home-streak {
  display: none; margin-left: auto; cursor: pointer; white-space: nowrap;
  font-size: 0.7rem; font-weight: 800; color: #e8590c;
  background: color-mix(in srgb, #e8590c 12%, transparent);
  border: 1px solid color-mix(in srgb, #e8590c 30%, transparent);
  padding: 0.2rem 0.6rem; border-radius: 999px;
}
.home-card__t { display: flex; align-items: center; gap: 0.35rem; }

.home-start__arrow { margin-left: 0.2rem; font-weight: 800; }

.home-sec h3 { letter-spacing: -0.01em; }

/* 손그림 아이콘 — 자체 색을 쓰므로 currentColor 로 덮지 않는다 */
.my-row__ico svg, .my-money__t svg, .q-title svg, .q-reward svg, .q-sub svg,
.home-card__t svg, .home-tool__ico svg, #game-hud svg, #game-nav svg,
#room-body button svg, #farm-body button svg { flex-shrink: 0; }
.game-nav-emoji { opacity: 0.45; }
#game-nav button.active .game-nav-emoji { opacity: 1; }
.my-row__ico, .my-money__t svg, .home-tool__ico { color: inherit; }

/* ============================================================
   서재 책장 — 책등 색 + 살짝 들린 카드
   ============================================================ */
.lib-lede { margin: 0 0 0.85rem; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; }
.lib-row {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.lib-row:active { transform: translateX(2px); }
.lib-ico {
  flex-shrink: 0; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 37px; height: 37px; border-radius: 11px;
  background: var(--bg-tertiary); border: 1px solid var(--glass-border);
}
.lib-row .lib-body { border-top: 1px dashed var(--glass-border); padding-top: 0.75rem; margin-top: 0.1rem; }
.lib-row .lib-body:empty { display: none; }

/* ============================================================
   상담사 매칭 — 헤더·칩·카드 톤 통일
   ============================================================ */
.mk-title { font-size: 1.18rem; font-weight: 800; letter-spacing: -0.02em; font-family: var(--font-heading); }
.cc-chip { display: inline-flex; align-items: center; gap: 0.28rem; }
.cc-chip svg { flex-shrink: 0; }
.cc2-meta span { display: inline-flex; align-items: center; gap: 0.2rem; }
.cc2-meta svg, .cc2-book svg, .cc2-live svg, .cc2-links svg { flex-shrink: 0; vertical-align: -2px; }
.cc2-book b, .cc2-live b { display: inline-flex; align-items: center; gap: 0.25rem; justify-content: center; }
.cc2-links button { display: inline-flex; align-items: center; gap: 0.25rem; }

/* ============================================================
   게임 타이포 확대 — 작은 글씨 가독성 (레이아웃 유지)
   ============================================================ */
.game-nav-label { font-size: 0.72rem; font-weight: 800; }
#game-nav button { padding: 0.5rem 0 0.55rem; gap: 0.15rem; }
.game-nav-emoji svg { width: 23px; height: 23px; }

/* 아주 좁은 폭에서만 돌봄 라벨을 한 단계 줄인다 */
@media (max-width: 359px) {
  .care-lbl { font-size: 0.66rem; }
  .game-nav-label { font-size: 0.66rem; }
}

/* 서재·마이 리스트 보조문구도 한 단계 위로 */
.my-row__txt > span { font-size: 0.76rem; }
.lib-row .lib-body { font-size: 0.86rem; }
.game-view-tip { font-size: 0.8rem; }

/* ============================================================
   탭 헤더 통일 — 모든 탭이 같은 리듬으로 시작한다
   ============================================================ */
.tab-lede { margin: 0 1.25rem 0.9rem; font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; flex-shrink: 0; }
.head-chip {
  all: unset; box-sizing: border-box; margin-left: auto; flex-shrink: 0; cursor: pointer;
  font-size: 0.74rem; font-weight: 800; color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
  padding: 0.28rem 0.7rem; border-radius: 999px; white-space: nowrap;
}
#tab-mypage .my-hero { margin-top: 0.3rem; }

/* 헤더 칩 아이콘 정렬 */
.head-chip { display: inline-flex; align-items: center; gap: 0.28rem; }
.head-chip svg { flex-shrink: 0; }

/* ============================================================
   상담사별 채팅방 — 우렁의사 초록 / 햇님 주황 / 달님 보라 / 소나무 진초록
   --chat-accent 는 updatePersonaBar() 가 #tab-chat 에 꽂아준다
   /* 상담사별 채팅방 */
   ============================================================ */
#tab-chat { --chat-accent: var(--accent-primary); }
#chat-messages {
  background:
    radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--chat-accent) 13%, transparent), transparent 70%);
}
#tab-chat .message.bot .message-content,
#tab-chat .message.bot .message-bubble {
  background: color-mix(in srgb, var(--chat-accent) 10%, var(--bg-tertiary));
  border: 1px solid color-mix(in srgb, var(--chat-accent) 24%, var(--glass-border));
}
#tab-chat .message.user .message-content,
#tab-chat .message.user .message-bubble {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--chat-accent) 88%, #fff),
    var(--chat-accent));
}
#tab-chat .message.bot .message-avatar {
  background: color-mix(in srgb, var(--chat-accent) 10%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--chat-accent) 38%, transparent);
}
#chat-send.send-btn:not(:disabled) {
  background: var(--chat-accent);
  border-color: transparent;
  color: #fff;
}
#tab-chat .input-wrapper:focus-within {
  border-color: color-mix(in srgb, var(--chat-accent) 55%, transparent);
}
#btn-program {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--chat-accent) 82%, #fff),
    var(--chat-accent)) !important;
}

/* 입력창 플레이스홀더 — 한 줄을 넘겨 잘리는 일이 없게 */
#chat-input::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 채팅 탭은 상담사 바가 곧 헤더다 — 그 위에 빈 10px 을 두지 않는다 */
/* 채팅 탭 상단 붙이기 */
body.header-hidden #tab-chat { padding-top: 0; }

/* 입력창 위 흰 띠 — 페이드가 88% 에서 뚝 끊겨 경계선처럼 보이던 문제.
   구간을 길게 잡아 서서히 사라지게 한다. (배경색은 그대로) */
/* 입력창 페이드 */
/* 그라데이션은 반투명 구간이 말풍선 위에 얹혀 '띠' 처럼 보인다.
   단색으로 덮고, 메시지 영역 아래 여백을 넉넉히 줘서 글이 가려지지 않게 한다. */
#tab-chat .chat-input-area {
  padding-top: 0.75rem;
  background: var(--bg-primary);
}
#tab-chat .chat-messages { padding-bottom: calc(var(--chat-input-h, 158px) + 1rem); }
body.kb-open #tab-chat .chat-messages { padding-bottom: calc(var(--chat-input-h, 96px) + 0.8rem); }
