/* ──────────────────────────────────────────────
   MindBuddi × 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 (subtle lavender) ────────── */
.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;
}

.orb3 {
  width: 300px;
  height: 300px;
  top: 40%;
  left: 40%;
  background: radial-gradient(circle, rgba(213, 194, 237, 0.1), transparent 70%);
  animation-delay: -8s;
}

@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;
}

/* ── Voice CSS Removed ── */

.voice-info {
  text-align: left;
  flex: 1;
}

.voice-info h3 {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 600;
}

.voice-info span {
  font-size: 12px;
  color: var(--primary-darker);
  background: var(--primary-dim);
  padding: 2px 8px;
  border-radius: 4px;
}

.voice-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  transform: scale(0.5);
  transition: var(--transition);
}

.voice-option.selected .voice-check {
  opacity: 1;
  transform: scale(1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: white;
  border: none;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 30px;
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(213, 194, 237, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(213, 194, 237, 0.5);
}

/* ── 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;
}

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

.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;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.sidebar-track-section {
  padding: 0 16px;
  margin-bottom: 30px;
}

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

.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: 10px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  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);
}

.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;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

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

.nav-icon {
  font-size: 16px;
}

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

.info-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

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

.info-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.sutras-badge {
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  background: var(--primary-dim);
  border: 1px solid rgba(213, 194, 237, 0.3);
  font-size: 11px;
  color: var(--primary-darker);
}

/* ── IMDS Sidebar Footer ───────────────────────── */
.imds-sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

.imds-sidebar-footer span {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.imds-sidebar-footer span.deepfountain-text {
  font-family: 'Noto Serif KR', serif;
  font-size: 15px;
  font-weight: 600;
  color: #5a2e3f; /* Deep burgundy/maroon matching DeepFountain theme */
  text-transform: none;
  letter-spacing: 0.2px;
  font-style: italic;
  margin-left: -2px;
}

/* ── TTS Badge & Audio UI Removed ── */

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

/* ── Header ───────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.03);
}

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

.avatar-sm {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: white;
  object-fit: cover;
  border: 1px solid var(--border);
}

.chat-header h2 {
  font-family: 'Noto Serif KR', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  margin-right: 6px;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

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

.header-imds {
  display: flex;
  align-items: center;
}

.header-imds-logo {
  height: 28px;
  padding: 4px 10px;
  border-radius: 6px;
  object-fit: contain;
  border: 1px solid var(--border-light);
}

.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;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.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);
}

body.force-desktop-mode .view-mode-btn {
  display: inline-flex;
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  box-shadow: none;
}

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

.messages-area::-webkit-scrollbar {
  width: 5px;
}

.messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
  background: rgba(213, 194, 237, 0.4);
  border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ── Message bubbles ──────────────────────────── */
.message {
  display: flex;
  gap: 14px;
  animation: fadeSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 820px;
}

@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;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(213, 194, 237, 0.2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.bubble {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  padding: 16px 20px;
  line-height: 1.8;
  font-size: 14.5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble p+p {
  margin-top: 10px;
}

.bubble strong {
  color: var(--primary-darker);
}

.bubble.markdown-body p {
  margin-bottom: 10px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble.markdown-body p:last-child {
  margin-bottom: 0;
}

.bubble.markdown-body h1,
.bubble.markdown-body h2,
.bubble.markdown-body h3 {
  margin: 0 0 12px;
  font-family: 'Noto Serif KR', serif;
  color: var(--primary-darker);
  overflow-wrap: anywhere;
}

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

.bubble.markdown-body li {
  margin: 8px 0;
  padding-left: 0.15em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble.markdown-body li::marker {
  color: var(--text-primary);
}

.bubble.markdown-body li > p {
  display: inline;
  margin: 0;
}

.bubble.markdown-body li > p + p {
  display: block;
  margin-top: 8px;
}

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

.bubble.markdown-body * {
  max-width: 100%;
}

/* User message */
.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;
  box-shadow: 0 4px 16px rgba(213, 194, 237, 0.3);
  color: #2d1b4e;
}

.user-message .avatar {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  font-size: 18px;
  line-height: 1;
  border: none;
}

/* ── Quick prompts ────────────────────────────── */
.quick-prompts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.quick-btn {
  padding: 10px 10px;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(213, 194, 237, 0.5);
  background: rgba(213, 194, 237, 0.08);
  color: var(--primary-darker);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.35;
  word-break: keep-all;
}

.quick-btn:hover {
  background: rgba(213, 194, 237, 0.2);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.sources-container {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
}

.sources-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-darker);
  margin-bottom: 8px;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: white;
  border: 1px solid rgba(213, 194, 237, 0.35);
  font-size: 11.5px;
  color: var(--primary-darker);
}

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

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

.feedback-btns {
  display: flex;
  gap: 8px;
}

.feedback-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ── Sources ──────────────────────────────────── */
.sources-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--primary-dim);
  border: 1px solid rgba(213, 194, 237, 0.3);
  font-size: 11.5px;
  color: var(--primary-darker);
}

.source-sim {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(213, 194, 237, 0.1);
  padding: 1px 5px;
  border-radius: 10px;
}

/* ── Image gallery ────────────────────────────── */
.images-gallery {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.img-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-white);
  cursor: pointer;
  transition: var(--transition);
  width: 160px;
  flex-shrink: 0;
}

.img-card:hover {
  transform: scale(1.03);
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(213, 194, 237, 0.3);
}

.img-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.img-card .img-label {
  padding: 6px 8px;
  font-size: 10.5px;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Image 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: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  max-width: 800px;
  width: 90vw;
  max-height: 90vh;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  position: relative;
  background: var(--bg-white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header-tabs {
  display: flex;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
}

.modal-tab-btn {
  padding: 18px 24px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  font-family: inherit;
}

.modal-tab-btn.active {
  color: var(--primary-darker);
  border-bottom-color: var(--primary);
}

.modal-body-content {
  flex: 1;
  overflow-y: auto;
  min-height: 350px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-view-text {
  padding: 50px 40px;
  width: 100%;
  max-width: 650px;
  text-align: center;
  animation: fadeSlideIn 0.3s ease;
}

.trans-header {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.trans-icon {
  font-size: 32px;
}

.trans-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 22px;
  color: var(--primary-darker);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.trans-text {
  font-size: 18px;
  line-height: 2;
  color: var(--text-primary);
  font-weight: 400;
  word-break: keep-all;
}

.modal-view-image {
  padding: 30px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeSlideIn 0.3s ease;
}

.modal-view-image img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(213, 194, 237, 0.25);
  border: 1px solid var(--border-light);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

.split-modal {
  max-width: 1040px;
  width: 92vw;
  max-height: 90vh;
}

.split-modal .modal-body-content {
  overflow: hidden;
  align-items: stretch;
  justify-content: stretch;
}

.modal-split-view {
  display: flex;
  width: 100%;
  min-height: 540px;
}

.modal-left,
.modal-right {
  flex: 1;
  overflow-y: auto;
}

.modal-left {
  padding: 28px;
  background: #faf8fe;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-left img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 10px 34px rgba(213, 194, 237, 0.22);
}

.modal-right {
  padding: 32px 30px;
  background: white;
}

.img-hint {
  font-size: 11.5px;
  color: var(--primary-darker);
  margin-top: 8px;
  opacity: 0.85;
}

mark {
  background: linear-gradient(transparent 58%, #fff0a9 58%);
  padding: 0 1px;
}

/* ── Typing indicator ─────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.loading-status-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  padding: 16px 20px;
  min-width: 250px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.loading-status-text {
  font-size: 13.5px;
  color: var(--primary-darker);
  margin-bottom: 10px;
  min-height: 20px;
  font-weight: 500;
}

.loading-progress-container {
  width: 100%;
  height: 6px;
  background: var(--bg-light);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-darker));
  border-radius: 4px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(213, 194, 237, 0.5);
}

/* ── Input area ───────────────────────────────── */
.input-area {
  padding: 20px 32px 24px;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.03);
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px 10px 20px;
  transition: var(--transition);
}

.input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(213, 194, 237, 0.15);
  background: var(--bg-white);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14.5px;
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 140px;
  overflow-y: auto;
}

textarea::placeholder {
  color: var(--text-muted);
}

.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;
  transition: var(--transition);
  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;
}

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ── Responsive ───────────────────────────────── */
@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;
  }

  .imds-logo-wrapper,
  .sidebar-info {
    display: none;
  }

  .sidebar-logo {
    gap: 10px;
  }

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

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

  .logo-text span {
    display: block;
    margin-top: 2px;
    font-size: 10px;
  }

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

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

  .sidebar-track-section {
    padding: 0;
    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 110px;
    justify-content: center;
    padding: 11px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .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;
  }

  .header-imds {
    display: none;
  }

  .view-mode-btn {
    display: inline-flex;
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1200;
    box-shadow: 0 10px 24px rgba(213, 194, 237, 0.28);
  }

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

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

  .message {
    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;
  }

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

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

  .images-gallery {
    gap: 8px;
  }

  .img-card {
    width: 128px;
  }

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

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

  textarea {
    font-size: 14px;
  }

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

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

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

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

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

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

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

  .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: 1180px;
    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 .imds-logo-wrapper,
  body.force-desktop-mode .sidebar-info,
  body.force-desktop-mode .header-imds {
    display: flex;
  }

  body.force-desktop-mode .sidebar-logo-section {
    gap: 16px;
  }

  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: 24px;
  }

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

  body.force-desktop-mode .sidebar-track-section {
    padding: 0 16px;
    margin-bottom: 30px;
  }

  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: 12px 14px;
    font-size: 14px;
  }

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

  body.force-desktop-mode .view-mode-btn {
    position: static;
    top: auto;
    right: auto;
    z-index: auto;
    box-shadow: none;
  }

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

  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 20px;
    font-size: 14.5px;
    line-height: 1.8;
  }

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

  body.force-desktop-mode .input-area {
    padding: 20px 32px 24px;
  }

  body.force-desktop-mode .input-container {
    gap: 12px;
    padding: 10px 12px 10px 20px;
    border-radius: 16px;
  }

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

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

/* ── Consolation Modal ────────────────────────── */
.consolation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.consolation-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.consolation-modal {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1), 0 0 24px rgba(213, 194, 237, 0.2);
  transform: scale(0.9);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.consolation-overlay.active .consolation-modal {
  transform: scale(1);
}

.consolation-modal::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(213, 194, 237, 0.1), transparent 30%);
  animation: rotate-glow 10s linear infinite;
  z-index: -1;
}

@keyframes rotate-glow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.consolation-icon {
  font-size: 40px;
  margin-bottom: 20px;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.consolation-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 24px;
  color: var(--primary-darker);
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.consolation-text {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 30px;
  font-weight: 500;
}

.consolation-close {
  background: var(--user-bg);
  border: none;
  color: white;
  padding: 12px 30px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(213, 194, 237, 0.3);
}

.consolation-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(213, 194, 237, 0.5);
}

.anticipation-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 15px;
  font-style: italic;
}

/* ── Floating Gift Box ────────────────────────── */
.gift-box-trigger {
  position: fixed;
  bottom: 100px;
  right: 40px;
  width: 120px;
  height: 120px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 0 16px rgba(213, 194, 237, 0.15);
  animation: gift-bounce 3s ease-in-out infinite;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  pointer-events: none;
}

.gift-box-trigger.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@keyframes gift-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.gift-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.gift-status {
  font-size: 11px;
  color: var(--primary-darker);
  font-weight: 600;
  text-align: center;
}

.gift-status-msg {
  font-size: 13px;
  color: var(--primary-darker);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Consolation Modal Refinements ──────────────── */
.consolation-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  padding: 5px;
  background: var(--bg-light);
  transition: transform 0.3s ease;
  margin-bottom: 10px;
}

.logo-pulse {
  animation: logo-pulse 2s infinite ease-in-out;
}

@keyframes logo-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(213, 194, 237, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px 10px rgba(213, 194, 237, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(213, 194, 237, 0);
  }
}

.audio-status-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  min-height: 24px;
}

.gift-progress-container {
  width: 80%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.gift-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-deep));
  transition: width 0.3s ease;
}

.gift-box-trigger.ready {
  background: rgba(213, 194, 237, 0.08);
  border-color: var(--primary);
  animation: gift-shimmer 2s linear infinite;
}

@keyframes gift-shimmer {
  0% { box-shadow: 0 4px 16px rgba(213, 194, 237, 0.15); }
  50% { box-shadow: 0 4px 32px rgba(213, 194, 237, 0.4); }
  100% { box-shadow: 0 4px 16px rgba(213, 194, 237, 0.15); }
}

/* ── Audio Status UI ────────────────────────── */
.status-msg {
  font-size: 13px;
  color: var(--primary-darker);
}

.audio-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(213, 194, 237, 0.3);
  border-top-color: var(--primary-darker);
  border-radius: 50%;
  animation: audio-spin 1s linear infinite;
}

@keyframes audio-spin {
  to { transform: rotate(360deg); }
}

.consolation-close.disabled {
  background: var(--bg-light);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ── Image & Translation UI ─────────────────────── */
.img-hint {
  font-size: 11.5px;
  color: var(--primary-darker);
  margin-top: 8px;
  opacity: 0.8;
}

.modal-translation {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-light);
  border-radius: 12px;
  border-left: 3px solid var(--primary);
  max-width: 800px;
  text-align: left;
}

.trans-title {
  color: var(--primary-darker);
  font-size: 14px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.trans-text {
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Audio Status & Progress ───────────────────── */
.audio-status {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-light);
  border-radius: 8px;
  display: inline-block;
}
