/* ──────────────────────────────────────────────
   MindBuddhi × IMDS — Clean White Light Mode
   Primary Color: #d5c2ed (Lavender)
   ────────────────────────────────────────────── */

:root {
  --bg-white: #ffffff;
  --bg-light: #f8f7fc;
  --bg-page: #f3f1f9;
  --surface: #ffffff;
  --surface-hover: #f5f3fa;
  --border: #e8e4f0;
  --border-light: #f0ecf5;
  --primary: #d5c2ed;
  --primary-light: #e5d9f5;
  --primary-deep: #b49bd8;
  --primary-darker: #9a7bc4;
  --primary-glow: rgba(213, 194, 237, 0.3);
  --primary-dim: rgba(213, 194, 237, 0.12);
  --lavender: #d5c2ed;
  --lavender-dim: rgba(213, 194, 237, 0.15);
  --user-bg: linear-gradient(135deg, #d5c2ed, #b49bd8);
  --bot-bg: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5478;
  --text-muted: #9e96b8;
  --sidebar-w: 290px;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  overflow: hidden;
}

/* ── Background orbs ── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
  animation: drift 14s ease-in-out infinite alternate;
}

.orb1 {
  width: 500px;
  height: 500px;
  top: -200px;
  left: -150px;
  background: radial-gradient(circle, rgba(213, 194, 237, 0.2), transparent 70%);
}

.orb2 {
  width: 400px;
  height: 400px;
  bottom: -150px;
  right: -100px;
  background: radial-gradient(circle, rgba(213, 194, 237, 0.15), transparent 70%);
  animation-delay: -4s;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(20px, 30px) scale(1.05); }
}

/* ── Lotus Background ── */
.lotus-bg {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M50 10 C60 40 90 50 50 90 C10 50 40 40 50 10' fill='none' stroke='%23d5c2ed' stroke-opacity='0.06'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

/* ── App layout ── */
.app-wrapper {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 20px;
  flex-shrink: 0;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.03);
}

.sidebar-logo-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.imds-logo-wrapper {
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(213, 194, 237, 0.15);
  animation: pulse-glow 4s ease-in-out infinite;
}

.imds-logo {
  width: 100%;
  max-width: 230px;
  object-fit: contain;
  display: block;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 2px 12px rgba(213, 194, 237, 0.15); }
  50% { box-shadow: 0 4px 24px rgba(213, 194, 237, 0.35); }
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo-img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }

.logo-text h1 {
  font-family: 'Noto Serif KR', serif;
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(to right, var(--primary-darker), var(--primary-deep));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.track-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-light);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.track-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: inherit;
}

.track-btn:hover { background: rgba(213, 194, 237, 0.1); color: var(--primary-darker); }

.track-btn.active {
  background: white;
  color: var(--primary-darker);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(213, 194, 237, 0.25);
  border: 1px solid rgba(213, 194, 237, 0.2);
}

.sidebar-info { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

.sidebar-footer-logos {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 10px;
  margin-top: 10px;
}

.powered-by, .collaboration {
  display: flex;
  align-items: center;
  gap: 8px;
}

.powered-by span:first-child, .collaboration span:first-child {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.deepfountain-text {
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  font-weight: 700;
  color: #4a4a4a;
  font-style: italic;
}

.imds-logo-small {
  height: 14px;
  object-fit: contain;
}

.voice-ready-card {
  margin-bottom: 6px;
}

.voice-ready-btn {
  width: 100%;
  padding: 8px 10px;
  background-color: #eafbea;
  border: 1px solid #c9ebd0;
  color: #2b7a3d;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.voice-ready-btn:hover {
  background-color: #dcf2de;
}

.sutras-badge {
  background-color: #fdfcff;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 5px 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ── Chat main ── */
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-page); }

.chat-header {
  padding: 16px 32px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 { font-family: 'Noto Serif KR', serif; font-size: 17px; font-weight: 600; line-height: 1.2; }

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-sm {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: white;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 6px rgba(213, 194, 237, 0.2);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #4cd964;
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: 0 0 8px rgba(76, 217, 100, 0.5);
}

.status-text {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-toggle {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-darker);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-toggle:hover {
  background: white;
  box-shadow: 0 2px 6px rgba(213, 194, 237, 0.3);
}

.view-mode-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-light);
  color: var(--primary-darker);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.view-mode-btn:hover {
  background: var(--primary-dim);
  border-color: var(--primary);
}

@media (max-width: 768px) {
  .view-mode-btn { display: inline-flex; }
}

body.force-desktop-mode .view-mode-btn {
    display: inline-flex;
}

/* ── Force Desktop Mode ── */
.force-desktop-mode #appWrapper {
  width: 1200px !important;
  min-width: 1200px !important;
  height: 100vh !important;
  margin: 0 auto !important;
  position: relative !important;
}

.force-desktop-mode .sidebar {
  width: 290px !important;
  display: flex !important;
}

.force-desktop-mode .chat-main {
  flex: 1 !important;
}

/* ── Messages area ── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message { display: flex; gap: 14px; max-width: 820px; animation: fadeSlideIn 0.35s ease; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.message .avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px rgba(213, 194, 237, 0.2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  object-fit: cover;
}

.bubble {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  padding: 16px 22px;
  line-height: 1.8;
  font-size: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  position: relative;
}

/* Markdown Styles */
.bubble.markdown-body h1, .bubble.markdown-body h2, .bubble.markdown-body h3 {
  margin: 1em 0 0.5em; font-family: 'Noto Serif KR', serif; color: var(--primary-darker);
}
.bubble.markdown-body p { margin-bottom: 10px; }
.bubble.markdown-body strong { color: var(--primary-darker); background: linear-gradient(transparent 70%, var(--primary-glow) 70%); }

.user-message { flex-direction: row-reverse; align-self: flex-end; }
.user-message .bubble {
  background: var(--user-bg);
  border-color: rgba(213, 194, 237, 0.5);
  border-radius: 18px 4px 18px 18px;
  color: #ffffff;
}

.user-message .bubble p {
  color: #ffffff;
}

/* ── Feedback & Suggestions ── */
.quick-prompts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
  width: 100%;
}

.info-card {
  background: white;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(213, 194, 237, 0.08);
  margin-bottom: 0;
}

.info-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-darker);
  margin-bottom: 4px;
}

.info-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.qr-mobile-card {
  background: linear-gradient(135deg, #fdfbff 0%, #f3ebff 100%);
  border: 1px solid #e9deff;
  padding: 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 20px;
}

.qr-mobile-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(213, 194, 237, 0.25);
  border-color: var(--primary);
}

.qr-mobile-icon {
  width: 44px;
  height: 44px;
  background: white;
  padding: 4px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.qr-mobile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-mobile-text .qr-title {
  font-size: 14px;
  font-weight: 600;
  color: #4a4a4a;
  margin-bottom: 2px;
}

.qr-mobile-text .qr-subtitle {
  font-size: 11px;
  color: #9b59b6;
  font-weight: 500;
}

.quick-btn {
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid rgba(213, 194, 237, 0.4);
  background: white;
  color: var(--primary-darker);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  word-break: keep-all;
  white-space: normal;
  line-height: 1.3;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
}


.quick-btn:hover { background: var(--lavender-dim); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(213, 194, 237, 0.2); }

.feedback-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.feedback-text { font-size: 11px; color: var(--text-muted); }
.feedback-btns { display: flex; gap: 6px; }
.feedback-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.feedback-btn:hover { border-color: var(--primary); transform: scale(1.1); }
.feedback-btn.active { background: var(--primary-dim); border-color: var(--primary); }

.voice-output-wrap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
}

.voice-output-hint {
  position: relative;
  max-width: 170px;
  padding: 7px 10px;
  border: 1px solid rgba(34,197,94,0.22);
  border-radius: 8px;
  background: rgba(240,253,244,0.96);
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  white-space: nowrap;
}

.voice-output-hint::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-top: 1px solid rgba(34,197,94,0.22);
  border-right: 1px solid rgba(34,197,94,0.22);
  background: rgba(240,253,244,0.96);
  transform: translateY(-50%) rotate(45deg);
}

.voice-output-btn {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  color: #15803d;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all 0.2s ease;
  padding: 2px;
}
.voice-icon {
  position: relative;
  z-index: 2;
}
.voice-ring {
  position: absolute;
  inset: -1px;
  width: 36px;
  height: 36px;
  transform: rotate(-90deg);
  z-index: 1;
  pointer-events: none;
}
.voice-ring-track,
.voice-ring-progress {
  fill: none;
  stroke-width: 2.4;
}
.voice-ring-track {
  stroke: rgba(34,197,94,0.16);
  opacity: 0;
}
.voice-ring-progress {
  stroke: #22c55e;
  stroke-linecap: round;
  stroke-dasharray: 97.39;
  stroke-dashoffset: var(--voice-ring-offset, 97.39);
  transition: stroke-dashoffset 0.16s linear;
  opacity: 0;
}
.voice-output-btn:hover,
.voice-output-btn.playing {
  border-color: #22c55e;
  background: rgba(236,253,245,0.96);
  transform: translateY(-1px);
}

/* ── Sources ── */
.voice-output-btn.loading {
  width: 34px;
  border-radius: 50%;
  border-color: transparent;
  background: white;
  cursor: wait;
}
.voice-output-btn.loading .voice-ring-track,
.voice-output-btn.loading .voice-ring-progress {
  opacity: 1;
}
.voice-output-btn.error {
  border-color: #ef4444;
  color: #dc2626;
  background: rgba(254,242,242,0.96);
}

.sources-container { margin-top: 16px; padding: 12px; background: var(--bg-light); border-radius: 12px; }
.sources-title { font-size: 12px; font-weight: 700; color: var(--primary-darker); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.source-tag {
  display: inline-block;
  font-size: 11.5px;
  color: var(--primary-darker);
  background: white;
  padding: 4px 10px;
  border-radius: 6px;
  margin: 0 6px 6px 0;
  border: 1px solid var(--border);
  word-break: keep-all;
}

/* ── Image Gallery ── */
.images-gallery { display: flex; gap: 12px; overflow-x: auto; margin-top: 14px; padding-bottom: 8px; }
.images-gallery::-webkit-scrollbar { height: 6px; }
.images-gallery::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }
.img-card {
  width: 180px; flex-shrink: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
  background: white; cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.img-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: 0 8px 16px rgba(164,72,212,0.15); }
.img-card img { width: 100%; height: 260px; object-fit: cover; object-position: top; background: #fdfdfd; padding: 4px; }
.img-card .img-label {
  padding: 10px; font-size: 11px; text-align: center; color: var(--text-secondary);
  background: var(--bg-light); border-top: 1px solid var(--border-light); 
  line-height: 1.4; word-break: keep-all; min-height: 48px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Highlighting ── */
mark { background: linear-gradient(120deg, #fff2ac 0%, #fff2ac 100%); background-repeat: no-repeat; background-size: 100% 80%; background-position: 0 80%; padding: 0 2px; }

/* ── Input ── */
.input-area { padding: 12px 24px 10px; background: var(--bg-white); border-top: 1px solid var(--border); }
.input-container {
  max-width: 900px; margin: 0 auto; display: flex; gap: 12px; background: var(--bg-light);
  padding: 8px 16px; border-radius: 24px; border: 1px solid var(--border); transition: var(--transition);
}
.input-container:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); background: white; }
textarea { flex: 1; background: none; border: none; outline: none; padding: 8px 0; font-size: 16px; font-family: inherit; resize: none; overflow-y: auto; }
.input-hint {
  max-width: 900px; margin: 5px auto 0; font-size: 11px;
  color: var(--text-muted); text-align: center; letter-spacing: 0.2px; opacity: 0.75;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal-content {
  width: 90vw; max-width: 900px; height: 85vh; background: white; border-radius: 24px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.1);
}
.modal-header-tabs { display: flex; background: var(--bg-light); border-bottom: 1px solid var(--border); }
.modal-tab-btn { flex: 1; padding: 20px; border: none; background: none; font-size: 16px; font-weight: 700; cursor: pointer; color: var(--text-muted); }
.modal-tab-btn.active { color: var(--primary-darker); border-bottom: 3px solid var(--primary); }
.modal-body-content { flex: 1; display: flex; overflow: hidden; }
.modal-split-view { display: flex; width: 100%; height: 100%; }
.modal-left, .modal-right { flex: 1; padding: 40px; overflow-y: auto; }
.modal-left { border-right: 1px solid var(--border-light); background: #fafafa; display: block; text-align: center; }
.modal-left img { width: 100%; height: auto; min-height: 200px; object-fit: contain; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.1); margin: 0 auto; display: block; }
.modal-right { background: white; font-size: 18px; line-height: 2; word-break: keep-all; }
.modal-close { position: absolute; top: 20px; right: 20px; background: rgba(0,0,0,0.05); border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 20px; }

/* ── Setup/Intro Modal ── */
.setup-modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(8px);
  z-index: 3000; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease;
}

.setup-modal-content {
  background: white; width: 90%; max-width: 500px;
  border-radius: 24px; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex; flex-direction: column; gap: 24px;
}

.setup-modal-header { text-align: center; }
.setup-logo { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 12px; object-fit: cover; }
.setup-modal-header h2 { font-family: 'Noto Serif KR', serif; font-size: 22px; color: var(--primary-darker); font-weight: 600; }

.meaning-box {
  background: var(--bg-light); border-radius: 12px; padding: 16px;
  font-size: 14.5px; line-height: 1.6; color: var(--text-secondary); text-align: center;
}
.meaning-box strong { color: var(--primary-deep); font-weight: 600; }
.lang-selection-box { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border-light); }
.lang-selection-box h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.lang-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.lang-options { display: flex; gap: 12px; }
.lang-opt-btn {
  flex: 1; padding: 12px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--bg-light); color: var(--text-secondary); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all 0.2s ease;
}
.lang-opt-btn:hover { border-color: var(--primary); background: rgba(213,194,237,0.05); }
.lang-opt-btn.active {
  border-color: var(--primary-darker); background: rgba(213,194,237,0.15);
  color: var(--primary-darker); box-shadow: 0 4px 12px rgba(213,194,237,0.25);
}

.voice-selection-box h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.voice-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

.voice-options { display: flex; flex-direction: column; gap: 10px; }
.voice-option {
  position: relative; display: flex; align-items: center; padding: 16px;
  border-radius: 12px; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.voice-option input[type="radio"] { display: none; }

.voice-option.active { border-color: #22c55e; background: rgba(34,197,94,0.08); box-shadow: 0 4px 12px rgba(34,197,94,0.18); }
.voice-option.disabled { opacity: 0.5; cursor: not-allowed; background: #fafafa; }

.voice-option-content { display: flex; flex-direction: column; gap: 4px; }
.voice-name { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.voice-tag { font-size: 12px; color: #a448d4; font-weight: 500; background: rgba(164,72,212,0.1); padding: 2px 8px; border-radius: 20px; align-self: flex-start; }
.voice-option.active .voice-tag { color: #15803d; background: rgba(34,197,94,0.14); }
.voice-option.disabled .voice-tag { color: var(--text-muted); background: var(--border); }

.setup-modal-footer { display: flex; justify-content: center; margin-top: 10px; }
.start-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-darker)); color: white;
  border: none; border-radius: 30px; padding: 16px 48px; font-size: 17px; font-weight: 600;
  cursor: pointer; transition: all 0.3s ease; box-shadow: 0 8px 24px var(--primary-glow);
}
.start-btn:hover {
  transform: translateY(-2px); box-shadow: 0 12px 30px rgba(154,123,196,0.5);
}

/* ── Multi-step Modal ── */
.setup-step { animation: fadeIn 0.3s ease; }
.step-desc { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.setup-modal-footer {
  display: flex; justify-content: center; align-items: center;
  flex-direction: column; gap: 10px; margin-top: 10px;
}

.skip-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 13px; cursor: pointer; text-decoration: underline; padding: 4px;
  transition: color 0.2s;
}
.skip-btn:hover { color: var(--primary); }

.setup-step-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; gap: 12px;
}

.nav-back-btn {
  background: var(--bg-light); border: 1px solid var(--border);
  border-radius: 20px; padding: 10px 20px; font-size: 14px;
  color: var(--text-secondary); cursor: pointer; transition: all 0.2s;
}
.nav-back-btn:hover { background: white; }

.step-next-btn { padding: 12px 28px; font-size: 15px; }
.step-next-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── MBTI Grid ── */
.mbti-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  overflow-y: auto; max-height: 320px; padding-right: 4px;
}

.mbti-card {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; padding: 12px 6px;
  border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--bg-light); cursor: pointer;
  transition: all 0.2s ease; text-align: center;
}
.mbti-card:hover { border-color: var(--primary); background: rgba(213,194,237,0.1); transform: translateY(-2px); }
.mbti-card.selected {
  border-color: var(--primary-darker); background: rgba(213,194,237,0.2);
  box-shadow: 0 4px 12px rgba(213,194,237,0.3);
}

.mbti-type {
  font-family: 'Noto Sans KR', sans-serif; font-weight: 700; font-size: 14px;
  color: var(--primary-darker); letter-spacing: 0.5px;
}
.mbti-name { font-size: 11px; color: var(--text-muted); }

/* ── Zodiac Grid ── */
.zodiac-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}

.zodiac-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--bg-light);
  cursor: pointer; font-size: 24px; transition: all 0.2s ease;
  line-height: 1;
}
.zodiac-card span { font-size: 11px; color: var(--text-muted); font-family: 'Noto Sans KR', sans-serif; }
.zodiac-card:hover { border-color: var(--primary); background: rgba(213,194,237,0.12); transform: translateY(-2px); }
.zodiac-card.selected {
  border-color: var(--primary-darker); background: rgba(213,194,237,0.22);
  box-shadow: 0 4px 14px rgba(213,194,237,0.35);
}

/* ── Profile Badge ── */
.profile-badge {
  margin-top: 8px; padding: 6px 12px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(213,194,237,0.25), rgba(164,72,212,0.1));
  border: 1px solid rgba(213,194,237,0.5); font-size: 12px;
  color: var(--primary-darker); font-weight: 600; text-align: center;
  animation: fadeIn 0.3s ease; cursor: pointer;
}
.profile-badge:hover { background: rgba(213,194,237,0.35); }

/* ── Personality Track Button ── */
.track-btn-personality { border-color: rgba(164,72,212,0.25) !important; }
.track-btn-personality.active, .track-btn-personality:hover {
  background: linear-gradient(135deg, rgba(213,194,237,0.3), rgba(164,72,212,0.15)) !important;
  border-color: var(--primary) !important;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Setup content scroll for smaller screens ── */
.setup-modal-content { max-height: 92vh; overflow-y: auto; }

/* ── CSS version bump to v=15 ── */
/* ── Typing/Loading Indicator ─────────────────── */
.typing-indicator {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  max-width: 820px;
  margin: 10px 0;
  animation: fadeIn 0.4s ease;
}

.loading-status-box {
  background: white;
  border: 1px solid rgba(213, 194, 237, 0.3);
  border-radius: 20px;
  padding: 20px 24px;
  min-width: 320px;
  box-shadow: 0 10px 30px rgba(213, 194, 237, 0.15);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.loading-status-text {
  font-size: 14px;
  color: var(--primary-darker);
  font-weight: 600;
  letter-spacing: -0.2px;
}

.loading-progress-container {
  width: 100%;
  height: 10px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #A448D4, #D5C2ED);
  border-radius: 10px;
  transition: width 0.2s linear;
  box-shadow: 0 0 10px rgba(164, 72, 212, 0.4);
  position: relative;
}

.loading-progress-bar::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Mobile parity with mindbuddi_clean_export_v4 */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.sidebar-track-section {
  margin-bottom: 18px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  padding-left: 4px;
}

.nav-btn,
.icon-btn,
.send-btn {
  font-family: inherit;
  transition: var(--transition);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-light);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary-darker);
}

.logo-text span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-light);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--primary-dim);
  color: var(--primary-darker);
  border-color: var(--primary);
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.bubble,
.bubble.markdown-body p,
.bubble.markdown-body li,
.bubble.markdown-body h1,
.bubble.markdown-body h2,
.bubble.markdown-body h3 {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.bubble.markdown-body ol,
.bubble.markdown-body ul {
  margin: 10px 0;
  padding-inline-start: 1.45em;
  max-width: 100%;
}

.bubble.markdown-body pre,
.bubble.markdown-body code,
.bubble.markdown-body table,
.bubble.markdown-body blockquote,
.bubble.markdown-body * {
  max-width: 100%;
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(213, 194, 237, 0.35);
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(213, 194, 237, 0.5);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  .app-wrapper {
    flex-direction: column;
    height: 100dvh;
  }

  .sidebar {
    width: 100%;
    padding: 14px 14px 12px;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
  }

  .sidebar-logo-section {
    gap: 10px;
  }

  .sidebar-logo {
    gap: 10px;
    margin-bottom: 0;
  }

  .logo-img {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .logo-text h1 {
    font-size: 18px;
  }

  .logo-text span {
    font-size: 10px;
  }

  .sidebar-nav {
    margin-bottom: 0;
  }

  .nav-btn {
    justify-content: center;
    padding: 11px 14px;
    font-size: 13px;
  }

  .sidebar-track-section {
    margin-bottom: 0;
  }

  .section-label {
    margin-bottom: 8px;
    padding-left: 2px;
  }

  .track-selector {
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding: 4px;
    border-radius: 16px;
    scrollbar-width: none;
  }

  .track-selector::-webkit-scrollbar {
    display: none;
  }

  .track-btn {
    flex: 1 0 118px;
    justify-content: center;
    padding: 11px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .profile-badge {
    margin-top: 8px;
    font-size: 11px;
    padding: 6px 10px;
  }

  .sidebar-info {
    display: none;
  }

  .chat-main {
    min-height: 0;
  }

  .chat-header {
    padding: 12px 14px;
    gap: 10px;
  }

  .header-left {
    flex: 1;
    min-width: 0;
    gap: 10px;
  }

  .header-left > div {
    min-width: 0;
  }

  .avatar-sm {
    width: 38px;
    height: 38px;
  }

  .chat-header h2 {
    font-size: 16px;
  }

  .status-text {
    display: inline-block;
    font-size: 11px;
  }

  .header-actions {
    margin-left: auto;
    gap: 8px;
    flex-shrink: 0;
  }

  .lang-toggle {
    min-height: 34px;
    padding: 0 10px;
  }

  .view-mode-btn {
    display: inline-flex;
    min-height: 34px;
    padding: 0 12px;
    font-size: 12px;
    box-shadow: 0 10px 24px rgba(213, 194, 237, 0.22);
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .messages-area {
    padding: 16px 12px;
    gap: 16px;
  }

  .message,
  .typing-indicator {
    max-width: none;
    gap: 10px;
  }

  .message .avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .bubble {
    padding: 14px 15px;
    font-size: 14px;
    line-height: 1.7;
  }

  .voice-output-btn {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .voice-output-wrap {
    right: 8px;
    bottom: 8px;
    gap: 6px;
  }

  .voice-output-hint {
    max-width: 128px;
    padding: 6px 8px;
    font-size: 11px;
    white-space: normal;
  }

  .quick-prompts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .quick-btn {
    min-height: 50px;
    font-size: 11.5px;
    padding: 8px 6px;
  }

  .images-gallery {
    gap: 8px;
  }

  .img-card {
    width: 132px;
  }

  .img-card img {
    height: 190px;
  }

  .input-area {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .input-container {
    max-width: none;
    gap: 10px;
    padding: 8px 10px 8px 14px;
    border-radius: 18px;
  }

  textarea {
    font-size: 16px;
    max-height: 120px;
  }

  .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .input-hint {
    font-size: 10px;
    margin-top: 8px;
  }

  .loading-status-box {
    min-width: 0;
    width: min(76vw, 320px);
    padding: 16px 18px;
    border-radius: 16px;
  }

  .modal-content {
    width: calc(100vw - 20px);
    height: auto;
    max-height: calc(100dvh - 20px);
    border-radius: 18px;
  }

  .modal-body-content {
    overflow: auto;
  }

  .modal-split-view {
    flex-direction: column;
    min-height: auto;
  }

  .modal-left,
  .modal-right {
    padding: 20px 18px;
  }

  .modal-left {
    min-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .modal-tab-btn {
    padding: 15px 12px;
    font-size: 14px;
  }

  .setup-modal-overlay {
    align-items: flex-start;
    padding: 10px;
    overflow-y: auto;
  }

  .setup-modal-content {
    width: 100%;
    max-height: none;
    padding: 22px 18px;
    border-radius: 18px;
    gap: 18px;
  }

  .setup-modal-header h2 {
    font-size: 19px;
  }

  .meaning-box {
    padding: 14px;
    font-size: 13.5px;
  }

  .lang-options {
    flex-direction: column;
    gap: 8px;
  }

  .mbti-grid,
  .zodiac-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .setup-step-nav {
    position: sticky;
    bottom: 0;
    background: white;
    padding-top: 12px;
  }

  .feedback-area {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 768px) {
  html.force-desktop-mode,
  body.force-desktop-mode {
    overflow: auto;
  }

  body.force-desktop-mode .app-wrapper {
    flex-direction: row;
    min-width: 1200px;
    height: 100vh;
  }

  body.force-desktop-mode .sidebar {
    width: var(--sidebar-w);
    padding: 24px 20px;
    gap: 20px;
    border-right: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.03);
  }

  body.force-desktop-mode .sidebar-info {
    display: flex;
  }

  body.force-desktop-mode .sidebar-logo {
    margin-bottom: 20px;
  }

  body.force-desktop-mode .logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  body.force-desktop-mode .logo-text h1 {
    font-size: 20px;
  }

  body.force-desktop-mode .logo-text span {
    font-size: 11px;
  }

  body.force-desktop-mode .sidebar-nav {
    margin-bottom: 18px;
  }

  body.force-desktop-mode .nav-btn {
    justify-content: flex-start;
    padding: 12px 16px;
    font-size: 14px;
  }

  body.force-desktop-mode .track-selector {
    flex-direction: column;
    gap: 6px;
    overflow: visible;
    padding: 6px;
    border-radius: 14px;
  }

  body.force-desktop-mode .track-btn {
    flex: none;
    justify-content: flex-start;
    padding: 9px 12px;
    font-size: 13px;
  }

  body.force-desktop-mode .chat-header {
    padding: 16px 32px;
    gap: 0;
  }

  body.force-desktop-mode .avatar-sm {
    width: 44px;
    height: 44px;
  }

  body.force-desktop-mode .chat-header h2 {
    font-size: 17px;
  }

  body.force-desktop-mode .status-text {
    font-size: 12px;
  }

  body.force-desktop-mode .messages-area {
    padding: 32px;
    gap: 24px;
  }

  body.force-desktop-mode .message {
    max-width: 820px;
    gap: 14px;
  }

  body.force-desktop-mode .message .avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  body.force-desktop-mode .bubble {
    padding: 16px 22px;
    font-size: 15px;
    line-height: 1.8;
  }

  body.force-desktop-mode .quick-prompts {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  body.force-desktop-mode .img-card {
    width: 180px;
  }

  body.force-desktop-mode .img-card img {
    height: 260px;
  }

  body.force-desktop-mode .input-area {
    padding: 12px 24px 10px;
  }

  body.force-desktop-mode .input-container {
    max-width: 900px;
    gap: 12px;
    padding: 8px 16px;
    border-radius: 24px;
  }

  body.force-desktop-mode textarea {
    font-size: 15px;
  }

  body.force-desktop-mode .send-btn {
    width: 42px;
    height: 42px;
  }
}
