/* Root Variables */
:root {
  --color-primary: #3B82F6;
  --color-tutoring: #3B82F6;
  --color-creativity: #EC4899;
  --color-productivity: #10B981;
  --color-wellness: #8B5CF6;
  --color-bg: #f8f9fa;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;
  --color-white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* Layout */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-creativity) 100%);
  color: var(--color-white);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 100%;
}

.back-button {
  background: rgba(255, 255, 255, 0.2);
  color: var(--color-white);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.back-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.back-button:active {
  transform: translateY(0);
}

.header-title {
  flex: 1;
  text-align: center;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.header .subtitle {
  font-size: 0.95rem;
  opacity: 0.9;
  font-weight: 400;
}

/* Main Container */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 1px;
  background-color: var(--color-border);
}

/* Canvas Container */
.canvas-container {
  flex: 1;
  position: relative;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.loading-text { display: none !important; }

/* Speech Bubble - Animal Crossing Style */
.speech-bubble {
  position: fixed;
  transform: translate(-50%, -100%);
  max-width: 380px;
  min-width: 200px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #fffdf0 0%, #fff6d9 100%);
  border: 3px solid #b8860b;
  border-radius: 24px;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(184, 134, 11, 0.2),
    inset 0 -2px 0 rgba(184, 134, 11, 0.15);
  font-family: -apple-system, 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #4a2c00;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 1000;
  word-break: keep-all;
}

.speech-bubble.visible {
  opacity: 1;
  visibility: visible;
  animation: bubbleAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bubbleAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, 20px) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.speech-bubble-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.speech-bubble-arrow {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4rem;
  color: #b8860b;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: arrowBounceDown 1.4s ease-in-out infinite;
}

@keyframes arrowBounce {
  0%, 100% { transform: translateX(-50%) rotate(180deg) translateY(0); }
  50% { transform: translateX(-50%) rotate(180deg) translateY(-4px); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Sidebar */
.sidebar {
  width: 360px;
  background-color: var(--color-white);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border);
}

/* Agent Tabs */
.agent-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.5rem;
  padding: 1rem;
  background: linear-gradient(to bottom, var(--color-white), #f3f4f6);
  border-bottom: 1px solid var(--color-border);
}

.agent-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--color-white);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.75rem;
  font-weight: 600;
}

.agent-tab .emoji {
  font-size: 1.5rem;
}

.agent-tab .name {
  color: var(--color-text-light);
}

.agent-tab:hover {
  background-color: #f3f4f6;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.agent-tab.active {
  background-color: var(--color-bg);
  border-color: var(--color-primary);
}

.agent-tab[data-agent="tutoring"].active {
  border-color: var(--color-tutoring);
}

.agent-tab[data-agent="creativity"].active {
  border-color: var(--color-creativity);
}

.agent-tab[data-agent="productivity"].active {
  border-color: var(--color-productivity);
}

.agent-tab[data-agent="wellness"].active {
  border-color: var(--color-wellness);
}

.agent-tab.active .name {
  color: var(--color-text);
  font-weight: 700;
}

/* Music Control */
.music-control {
  padding: 0.75rem 1rem;
  background-color: #f9fafb;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.music-buttons {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.music-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  transition: all 0.2s ease;
  flex: 1;
  justify-content: center;
}

.music-pattern-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.8rem;
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.music-pattern-btn:not(:disabled):hover {
  background-color: var(--color-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.music-pattern-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.music-pattern-btn.active {
  background: linear-gradient(135deg, #ddd6fe, #c4b5fd);
  border-color: #8b5cf6;
  color: #5b21b6;
}

.music-toggle:hover {
  background-color: var(--color-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.music-toggle.playing {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #f59e0b;
  color: #92400e;
}

.music-toggle.playing .music-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

.music-hint {
  font-size: 0.7rem;
  color: var(--color-text-light);
  text-align: center;
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-light);
  text-align: center;
  font-size: 0.95rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
}

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

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.message.user .message-avatar {
  background-color: #3b82f6;
  color: #ffffff;
  order: 2;
}

.message.assistant .message-avatar {
  background-color: #059669;
  color: #ffffff;
  border: none;
}

.message-content {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  word-wrap: break-word;
  font-size: 0.95rem;
}

.message.user .message-content {
  background-color: var(--color-primary);
  color: var(--color-white);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background-color: #f3f4f6;
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

/* Active agent color accent */
.agent-tab[data-agent="tutoring"].active ~ .chat-container .message.assistant .message-content {
  background-color: #dbeafe;
  border-left: 3px solid var(--color-tutoring);
  padding-left: calc(1rem - 3px);
}

.agent-tab[data-agent="creativity"].active ~ .chat-container .message.assistant .message-content {
  background-color: #fce7f3;
  border-left: 3px solid var(--color-creativity);
  padding-left: calc(1rem - 3px);
}

.agent-tab[data-agent="productivity"].active ~ .chat-container .message.assistant .message-content {
  background-color: #d1fae5;
  border-left: 3px solid var(--color-productivity);
  padding-left: calc(1rem - 3px);
}

.agent-tab[data-agent="wellness"].active ~ .chat-container .message.assistant .message-content {
  background-color: #ede9fe;
  border-left: 3px solid var(--color-wellness);
  padding-left: calc(1rem - 3px);
}

/* Input Area */
.input-area {
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-white);
}

.chat-form {
  display: flex;
  gap: 0.75rem;
}

.message-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.message-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-button {
  padding: 0.75rem 1.5rem;
  background-color: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.send-button:hover {
  background-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.send-button:active {
  transform: translateY(0);
}

.send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Status */
.status {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--color-text-light);
  text-align: center;
  min-height: 1.2rem;
}

.status.loading {
  color: var(--color-primary);
  animation: pulse 1.5s ease-in-out infinite;
}

.status.error {
  color: #ef4444;
  background-color: #fee2e2;
  border-radius: 4px;
  padding: 0.75rem 1rem;
}

/* Scrollbar Styling */
.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: var(--color-bg);
}

.messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 320px;
  }

  .message-content {
    max-width: 85%;
  }
}

/* Higgsfield Realistic Mode Control */
.higgsfield-control {
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.higgsfield-buttons {
  display: flex;
  gap: 0.75rem;
}

.auto-realistic-toggle,
.realistic-toggle,
.generate-video-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background-color: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  position: relative;
}

.auto-realistic-toggle:hover,
.realistic-toggle:hover,
.generate-video-btn:hover {
  background-color: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.auto-realistic-toggle.active,
.realistic-toggle.active {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  border-color: #ffa500;
  color: #8b6914;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.generate-video-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--color-border);
}

.generate-video-btn.loading {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: var(--color-primary);
  animation: pulse 1.5s ease-in-out infinite;
}

.realistic-icon,
.video-icon {
  font-size: 1.1rem;
}

.higgsfield-hint {
  font-size: 0.8rem;
  color: var(--color-text-light);
  text-align: center;
  padding: 0 0.5rem;
}

/* Video Modal */
.video-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.video-modal.visible {
  opacity: 1;
  visibility: visible;
}

.video-modal-content {
  background: var(--color-white);
  border-radius: 16px;
  padding: 0;
  max-width: 90%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.video-modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.video-modal-header h2 {
  font-size: 1.5rem;
  color: var(--color-text);
  margin: 0;
}

.video-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-light);
  transition: color 0.2s ease;
}

.video-modal-close:hover {
  color: var(--color-text);
}

.video-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

.video-loading {
  text-align: center;
  color: var(--color-text-light);
}

.video-loading-spinner {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
  .sidebar {
    width: 320px;
  }

  .message-content {
    max-width: 85%;
  }
}

@media (max-width: 1024px) {
  .header-content {
    flex-direction: column;
    gap: 0.5rem;
  }

  .header-title {
    width: 100%;
  }

  .back-button {
    width: 100%;
  }
}

@media (max-width: 768px) {
  #app {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .main-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* 📱 1. 모바일 3D 창 세로로 길게 확장 (55vh, 최소 380px) */
  .canvas-container {
    width: 100%;
    height: 55vh;
    min-height: 380px;
    max-height: 60vh;
    flex: 0 0 55vh;
    position: relative;
  }

  /* 📱 2. 사이드바 레이아웃 */
  .sidebar {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    border-left: none;
    border-top: 1px solid var(--color-border);
    overflow: hidden;
    min-height: 0;
    background: #ffffff;
  }

  /* 📱 3. 헤더 바 (브랜드 + 음성 On 버튼 등) */
  .sidebar-header-bar {
    padding: 0.45rem 0.8rem;
    gap: 0.3rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  .sidebar-brand-row {
    margin-bottom: 0.15rem;
  }

  .brand-title {
    font-size: 0.88rem;
  }

  .side-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
  }

  .sidebar-action-row {
    gap: 0.4rem;
  }

  /* 📱 4. 채팅 컨테이너 */
  .chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  /* 📱 5. 채팅 입력창을 음성 On 버튼 바로 아래로 직결! (order: -1) */
  .input-area {
    order: -1;
    padding: 0.5rem 0.75rem;
    background: #ffffff;
    border-top: none;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
    z-index: 10;
  }

  .chat-form {
    gap: 0.5rem;
  }

  .message-input {
    padding: 0.6rem 0.85rem;
    font-size: 0.88rem;
    border-radius: 8px;
  }

  .send-button {
    padding: 0.6rem 1.0rem;
    font-size: 0.88rem;
    border-radius: 8px;
  }

  /* 📱 6. 이전 대화 메시지는 입력창 아래에 스크롤로 배치 */
  .messages {
    order: 1;
    flex: 1;
    overflow-y: auto;
    padding: 0.65rem 0.75rem;
    gap: 0.6rem;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

  .message-welcome {
    padding: 0.4rem;
    font-size: 0.82rem;
  }

  .message-bubble {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
  }

  .video-modal-content {
    max-width: 95%;
    max-height: 80vh;
  }

  .video-modal-header {
    padding: 1rem 1.5rem;
  }

  .video-modal-header h2 {
    font-size: 1.2rem;
  }
}

/* Background Images Control */
.background-images-control {
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--color-border);
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.backgrounds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.9rem;
}

.refresh-btn {
  padding: 0.4rem 0.6rem;
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn:hover {
  background-color: var(--color-bg);
  border-color: var(--color-primary);
  transform: rotate(180deg);
  transition: all 0.3s ease;
}

.refresh-btn.loading {
  animation: spin 1s linear infinite;
}

.backgrounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 0.5rem;
  max-height: 120px;
  overflow-y: auto;
}

.background-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--color-border);
  transition: all 0.2s ease;
}

.background-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.background-thumbnail {
  width: 100%;
  height: 60px;
  object-fit: cover;
  display: block;
}

.apply-bg-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(59, 130, 246, 0.8);
  color: white;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.background-item:hover .apply-bg-btn {
  opacity: 1;
}

.no-backgrounds {
  text-align: center;
  color: var(--color-text-light);
  font-size: 0.85rem;
  padding: 1rem;
  grid-column: 1 / -1;
}

/* Generate Music Button */
.generate-music-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background-color: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.generate-music-btn:hover {
  background-color: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.generate-music-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.generate-music-btn.loading {
  background-color: rgba(147, 112, 219, 0.1);
  border-color: #8b5cf6;
  animation: pulse 1.5s ease-in-out infinite;
}

.music-icon {
  font-size: 1.1rem;
}

/* Animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* API Settings Button & Modal */
.api-settings-btn {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  margin-left: 8px;
}

.api-settings-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.api-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.api-modal.visible {
  display: flex;
}

.api-modal-content {
  background: #1e1e30;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  width: 90%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  color: #fff;
}

.api-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.api-modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.api-modal-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
}

.api-modal-close:hover {
  color: #fff;
}

.api-modal-body p {
  font-size: 0.92rem;
  color: #ccc;
  line-height: 1.5;
  margin-bottom: 12px;
}

.api-hint-box {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.84rem;
  color: #93c5fd;
  margin-bottom: 16px;
}

.api-input-group {
  margin-bottom: 16px;
}

.api-key-input {
  width: 100%;
  padding: 12px 14px;
  background: #111122;
  border: 1px solid #3b4261;
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.api-key-input:focus {
  outline: none;
  border-color: #60a5fa;
}

.api-modal-buttons {
  display: flex;
  gap: 10px;
}

.api-save-btn {
  flex: 2;
  padding: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.api-save-btn:hover {
  opacity: 0.9;
}

.api-clear-btn {
  flex: 1;
  padding: 12px;
  background: #2a2a3d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #aaa;
  font-weight: 500;
  cursor: pointer;
}

.api-clear-btn:hover {
  background: #36364d;
  color: #fff;
}

.api-key-status {
  margin-top: 12px;
  font-size: 0.85rem;
  text-align: center;
}

/* Voice Toggle Button & Message TTS Button */
.voice-toggle-btn {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  margin-left: 6px;
}

.voice-toggle-btn:hover {
  background: rgba(59, 130, 246, 0.35);
  border-color: rgba(59, 130, 246, 0.6);
  transform: translateY(-1px);
  color: #fff;
}

.voice-toggle-btn.muted {
  background: rgba(100, 100, 100, 0.2);
  border-color: rgba(150, 150, 150, 0.3);
  color: #888;
}

.message-tts-btn {
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  margin-left: 6px;
  align-self: flex-end;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.2s;
}

.message-tts-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* API Verification Badge */
.api-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(147, 51, 234, 0.25) 100%);
  border: 1px solid rgba(147, 51, 234, 0.4);
  color: #c084fc;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 8px;
  margin-bottom: 4px;
  margin-left: 4px;
  letter-spacing: 0.02em;
}


/* ===================================================
   Right Window (Sidebar) Header & Controls
   =================================================== */
.sidebar {
  width: 380px;
  background-color: #1e1e2f;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  height: 100vh;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
}

.sidebar-header-bar {
  background: linear-gradient(180deg, #26263b 0%, #1c1c2d 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 1.25rem;
}

.brand-name {
  font-weight: 700;
  font-size: 1.02rem;
  color: #f3f4f6;
  letter-spacing: -0.01em;
}

.sidebar-action-row {
  display: flex;
  gap: 8px;
}

.side-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.side-back-btn {
  background: rgba(255, 255, 255, 0.07);
  color: #9ca3af;
  border-color: rgba(255, 255, 255, 0.12);
  padding: 5px 10px;
  font-size: 0.8rem;
}

.side-back-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.side-voice-btn {
  flex: 1;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.side-voice-btn:hover {
  background: rgba(16, 185, 129, 0.25);
}

.side-voice-btn.muted {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.side-api-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
}

.side-api-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35) 0%, rgba(168, 85, 247, 0.35) 100%);
  color: #e9d5ff;
}

.viz-header-row {
  margin-bottom: 2px;
}

.side-viz-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(13, 148, 136, 0.22) 100%);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.45);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.2px;
}

.side-viz-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.35) 0%, rgba(13, 148, 136, 0.38) 100%);
  color: #ffffff;
  border-color: rgba(52, 211, 153, 0.85);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.35);
}

.side-mask-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2) 0%, rgba(217, 119, 6, 0.2) 100%);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.2px;
}

.side-mask-btn:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.38) 0%, rgba(217, 119, 6, 0.38) 100%);
  color: #ffffff;
  border-color: rgba(245, 158, 11, 0.85);
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.35);
}

.side-led-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.45);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.2px;
}

.side-led-btn:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.38) 0%, rgba(59, 130, 246, 0.38) 100%);
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.85);
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.35);
}

/* Chat container dark styling integration */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #181826;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message.assistant .message-content {
  background: #252538;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.message.user .message-content {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
}

.input-area {
  padding: 14px 16px 10px 16px;
  background: #1e1e2f;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-form textarea.message-input {
  flex: 1;
  padding: 12px 14px;
  background: #141420;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1.5;
  font-family: inherit;
  resize: none;
  min-height: 48px;
  max-height: 180px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form textarea.message-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22);
  outline: none;
}

.chat-form textarea.message-input::placeholder {
  color: #71717a;
}

.chat-form .send-button {
  padding: 0 20px;
  height: 48px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-form .send-button:hover {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

.chat-form .send-button:active {
  transform: translateY(0);
}

.chat-form .send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-hint {
  margin-top: 8px;
  font-size: 0.76rem;
  color: #71717a;
  padding: 0 2px;
}


/* 말풍선 이름 라벨 태그 */
.speech-bubble-name {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b8860b;
  margin-bottom: 6px;
  background: rgba(184, 134, 11, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

/* 👤 오른쪽 파란색 캐릭터 (사용자 발화) 전용 말풍선 */
.user-speech-bubble {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 3px solid #0284c7;
  color: #0369a1;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(2, 132, 199, 0.25),
    inset 0 -2px 0 rgba(2, 132, 199, 0.15);
}

.user-speech-bubble .speech-bubble-name {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.12);
}

.user-speech-bubble .speech-bubble-arrow {
  color: #0284c7;
}


/* 🌿 왼쪽 AI 도사 말풍선: 언제나 사용자 말풍선보다 최상단(앞)에 표시 */
#speechBubble {
  z-index: 1020 !important;
}

/* 💬 큐레이터 말풍선: 가로 60% 넓게(380→608px), 한 번에 4줄 — 넘치면 최근 4줄이 보이도록 흘러감 */
#speechBubble {
  width: max-content;   /* 화면 오른쪽에 있어도 줄어들지 않게 */
  max-width: min(608px, 92vw);
  min-width: min(320px, 80vw);
  padding: 14px 24px 16px;
  text-align: left;
}
#speechBubble .speech-bubble-name { display: table; margin: 0 auto 6px; }
#speechBubble .speech-bubble-text {
  font-size: 1.02rem;
  line-height: 1.6;
  max-height: calc(1.6em * 4);
  overflow: hidden;
  scroll-behavior: smooth;
}

/* 👤 오른쪽 파란색 도사 (사용자 발화 말풍선): AI 도사 말풍선보다 아래 레이어에 배치 */
#userSpeechBubble,
.user-speech-bubble {
  z-index: 1000 !important;
}

/* 감정 큐레이터 바 차트 및 마크다운 출력 서식 개선 */
.message-content {
  white-space: pre-wrap !important;
  word-break: break-word;
}

.message-content pre,
.message-content code {
  font-family: 'Consolas', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 4px;
  border-radius: 4px;
}

/* ==============================================================================
   🎭 3D 뷰 컨트롤 및 분석 인터페이스 스타일
   ============================================================================== */

/* 2. 3D 뷰 내부: 3차원 공간에 떠다니는 입체 컨트롤 버튼들 */
.canvas-3d-floating-bar {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1010;
  display: flex;
  gap: 10px;
  animation: floatingControls 4s ease-in-out infinite;
}

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

.canvas-3d-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  color: #e2e8f0;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 
    0 8px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
}

.canvas-3d-pill-btn:hover {
  background: rgba(30, 41, 59, 0.9);
  color: #ffffff;
  border-color: rgba(168, 85, 247, 0.6);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.45);
}

.canvas-3d-close-btn {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.canvas-3d-close-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #ffffff;
}

/* 3. 사이드바 헤더 3D 토글 버튼 */
.side-3d-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2) 0%, rgba(147, 51, 234, 0.2) 100%);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
}

.side-3d-btn:hover {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.35) 0%, rgba(147, 51, 234, 0.35) 100%);
  color: #fff;
}

.side-3d-btn.off {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.15);
}

/* 4. 3D 뷰 토글 레이아웃 전환 */
.canvas-container {
  flex: 1.1;
  position: relative;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar {
  width: 480px;
  background-color: #1e1e2f;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  height: 100vh;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3D 뷰가 접혔을 때: 채팅 영역이 화면 전체로 확장되어 요약 리포트와 텍스트 입력을 쾌적하게 지원 */
.main-container.view-3d-collapsed .canvas-container {
  flex: 0 0 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.main-container.view-3d-collapsed .sidebar {
  width: 100% !important;
  flex: 1 !important;
  border-left: none;
}

.main-container.view-3d-collapsed .chat-container {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

.main-container.view-3d-collapsed .input-area {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
  border-radius: 12px 12px 0 0;
}

/* 5. 요약 리포트 하이라이트 스타일 */
.message.assistant .message-content h3:first-of-type {
  display: inline-block;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
  border: 1px solid rgba(168, 85, 247, 0.4);
  padding: 4px 10px;
  border-radius: 6px;
  color: #c084fc;
  margin-bottom: 8px;
}

/* 6. 분석 결과 보기 버튼 스타일 */
.canvas-result-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.35) 0%, rgba(59, 130, 246, 0.35) 100%) !important;
  border-color: rgba(52, 211, 153, 0.5) !important;
  color: #6ee7b7 !important;
  font-weight: 700 !important;
}

.canvas-result-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.5) 0%, rgba(59, 130, 246, 0.5) 100%) !important;
  color: #ffffff !important;
  border-color: rgba(52, 211, 153, 0.8) !important;
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.4) !important;
}

.side-result-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(59, 130, 246, 0.22) 100%) !important;
  color: #6ee7b7 !important;
  border-color: rgba(52, 211, 153, 0.45) !important;
  font-weight: 700 !important;
}

.side-result-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.38) 0%, rgba(59, 130, 246, 0.38) 100%) !important;
  color: #ffffff !important;
  border-color: rgba(52, 211, 153, 0.75) !important;
}

/* 분석 결과 강조 스크롤 애니메이션 */
.highlight-result {
  animation: resultGlow 2.5s ease-out;
}

@keyframes resultGlow {
  0% {
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.9), 0 0 30px rgba(52, 211, 153, 0.6);
    transform: scale(1.015);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.5), 0 0 15px rgba(52, 211, 153, 0.3);
  }
  100% {
    box-shadow: none;
    transform: scale(1);
  }
}

/* 7. 3D 감정 지도 및 가면 생성 상태 스타일 */
.canvas-result-btn.building,
.side-result-btn.building,
.side-viz-btn.building,
.side-mask-btn.building,
.side-led-btn.building {
  background: rgba(245, 158, 11, 0.28) !important;
  border-color: rgba(245, 158, 11, 0.7) !important;
  color: #fbbf24 !important;
  animation: vizPulseBuilding 1.4s infinite ease-in-out;
}

@keyframes vizPulseBuilding {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.canvas-result-btn.completed,
.side-result-btn.completed,
.side-viz-btn.completed,
.side-mask-btn.completed,
.side-led-btn.completed {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.55) 0%, rgba(99, 102, 241, 0.55) 100%) !important;
  border-color: rgba(52, 211, 153, 0.95) !important;
  color: #ffffff !important;
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.6) !important;
  animation: vizPulseCompleted 2s infinite ease-in-out;
}

@keyframes vizPulseCompleted {
  0%, 100% {
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 24px rgba(52, 211, 153, 0.85);
    transform: scale(1.04);
  }
}

.viz-card-banner {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 12px;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.viz-card-banner:hover {
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.22);
}

.viz-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viz-card-icon {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(168, 85, 247, 0.5));
}

.viz-card-body {
  flex: 1;
  min-width: 0;
}

.viz-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.2px;
  margin-bottom: 3px;
}

.viz-card-sub {
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.4;
}

.viz-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 2px;
}

.viz-card-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  color: #ffffff;
}

.viz-card-btn .btn-icon {
  font-size: 0.95rem;
}

.viz-btn-map {
  background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.35);
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.viz-btn-map:hover {
  background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(16, 185, 129, 0.5);
}

.viz-btn-text {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.35);
  border: 1px solid rgba(165, 180, 252, 0.4);
}

.viz-btn-text:hover {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(99, 102, 241, 0.5);
}

.viz-btn-mask {
  background: linear-gradient(135deg, #7c3aed 0%, #d97706 100%);
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.35);
  border: 1px solid rgba(192, 132, 252, 0.4);
}

.viz-btn-mask:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #f59e0b 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(217, 119, 6, 0.5);
}

.viz-btn-led {
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  box-shadow: 0 3px 12px rgba(2, 132, 199, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.viz-btn-led:hover {
  background: linear-gradient(135deg, #38bdf8 0%, #14b8a6 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(56, 189, 248, 0.5);
}




/* ==========================================================================
   👥 사용자 선택 (A-1 ~ D-4)
   ========================================================================== */
.user-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-picker-label {
  font-size: 0.75rem;
  color: #a1a1aa;
}
.user-select {
  background: rgba(255, 255, 255, 0.06);
  color: #f4f4f5;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.user-select option,
.user-select optgroup {
  background: #18181b;
  color: #f4f4f5;
}
.user-select.need-select {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35);
  animation: userPulse 0.5s ease-in-out 3;
}
@keyframes userPulse {
  50% { transform: scale(1.06); }
}
.user-gallery-link {
  font-size: 0.72rem;
  color: #93c5fd;
  text-decoration: none;
  white-space: nowrap;
}
.user-gallery-link:hover { text-decoration: underline; }
.side-btn.no-result {
  opacity: 0.4;
  cursor: not-allowed;
}
.viz-card-privacy {
  margin-top: 8px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: #a1a1aa;
}
.viz-btn-save {
  background: linear-gradient(135deg, #4b5563 0%, #1f2937 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}


/* ==========================================================================
   📄 *.txt 파일 드래그 앤 드롭(Drag & Drop) 스타일
   ========================================================================== */
.input-area {
  position: relative;
  transition: all 0.2s ease-in-out;
}

.input-area.drag-over {
  background-color: #ecfdf5 !important;
  border: 2px dashed #10b981 !important;
  border-radius: 12px;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.25) !important;
}

.message-input.drag-over {
  border-color: #10b981 !important;
  background-color: #ffffff !important;
}

.input-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--color-text-light);
}

.file-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  background-color: #f3f4f6;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text);
  transition: all 0.2s ease;
  user-select: none;
}

.file-attach-btn:hover {
  background-color: #e5e7eb;
  border-color: #10b981;
  color: #047857;
  transform: translateY(-1px);
}

/* ==========================================================================
   🔐 로그인 창 · 로그인 표시 · [다음 사람] 버튼
   ========================================================================== */
.login-modal { z-index: 3000; }
.login-content { max-width: 400px; }
.login-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #c4c4d0;
}
.login-input {
  font-size: 1.15rem;
  padding: 14px 16px;
  letter-spacing: 1px;
}
.login-pin {
  font-size: 1.5rem;
  letter-spacing: 10px;
  text-align: center;
}
.login-pin::placeholder {
  font-size: 1rem;
  letter-spacing: 2px;
}
.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
}
.login-btn:disabled { opacity: 0.6; cursor: wait; }
.login-status { min-height: 24px; }
.api-modal-body p.login-note {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: #9ca3af;
}
.login-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #a1a1aa;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}
.login-badge.logged-in {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(16, 185, 129, 0.12);
}
.side-logout-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==========================================================================
   🗺️ 감정지도 패널 (왼쪽 3D 화면 자리에 표시, 오른쪽 대화창 유지)
   ========================================================================== */
.map-panel {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #0b0b14;
}
.map-panel[hidden] { display: none; }
.map-panel-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #14141f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.map-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-panel-actions { display: flex; gap: 8px; flex-shrink: 0; }
.map-view-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-right: auto;
  margin-left: 4px;
  flex-shrink: 0;
}
.map-view-btn {
  padding: 4px 12px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: #a1a1aa;
  font-size: 0.8rem;
  cursor: pointer;
}
.map-view-btn:hover { color: #fff; }
.map-view-btn.active { background: rgba(139, 156, 255, 0.22); color: #fff; font-weight: 600; }
.map-panel-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #d4d4d8;
  font-size: 0.82rem;
  cursor: pointer;
}
.map-panel-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.map-panel-close {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.map-panel-close:hover { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); }
.map-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #0b0b14;
}
.canvas-container.map-open .speech-bubble { display: none !important; }
.side-btn.map-active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-color: transparent;
}

/* ==========================================================================
   📝 AI 답변 마크다운 화면 (제목·목록·인용·막대그래프)
   ========================================================================== */
.message-content.md {
  white-space: normal !important;
  line-height: 1.65;
}
.message-content.md > * { margin: 0; }
.message-content.md > * + * { margin-top: 0.55rem; }
.message-content.md h3,
.message-content.md h4 {
  font-size: 1.02rem;
  font-weight: 800;
  color: #f4f4f5;
  margin-top: 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.message-content.md h4 { font-size: 0.95rem; border-bottom: none; padding-bottom: 0; }
.message-content.md > h3:first-child,
.message-content.md > h4:first-child,
.message-content.md > .api-badge + h3,
.message-content.md > .api-badge + h4 { margin-top: 0.2rem; }
.message-content.md strong { color: #fff; font-weight: 700; }
.message-content.md em { color: #c4b5fd; font-style: normal; }
.message-content.md ul,
.message-content.md ol { padding-left: 1.2rem; }
.message-content.md li + li { margin-top: 0.3rem; }
.message-content.md li::marker { color: #818cf8; }
.message-content.md blockquote {
  border-left: 3px solid #818cf8;
  background: rgba(129, 140, 248, 0.1);
  padding: 0.6rem 0.8rem;
  border-radius: 0 8px 8px 0;
  color: #e0e7ff;
}
.message-content.md hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0.9rem 0;
}
.message-content.md pre {
  white-space: pre;
  overflow-x: auto;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
}
.message-content.md .md-family {
  margin-top: 0.8rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: #a5b4fc;
}
.message-content.md .md-bar {
  display: grid;
  grid-template-columns: minmax(7.5em, 34%) 1fr auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
  margin-top: 0.3rem;
}
.message-content.md .md-bar-label { color: #e5e7eb; }
.message-content.md .md-bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.message-content.md .md-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #a78bfa);
}
.message-content.md .md-bar.is-violence .md-bar-fill {
  background: linear-gradient(90deg, #ef4444, #f97316);
}
.message-content.md .md-bar-value {
  color: #a1a1aa;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.message-content.md .md-tag-violence {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.25);
  vertical-align: middle;
}

/* 🔊 [이어서 듣기] 버튼 */
.message-content .speech-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.7rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.45);
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.message-content .speech-more-btn:hover { background: rgba(99, 102, 241, 0.3); color: #fff; }
.message-content .speech-more-btn.playing {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-color: transparent;
}
.message-content.md > .speech-more-btn { align-self: flex-start; margin-top: 0.9rem; }

/* ==========================================================================
   🙋 질문 카드 모드 — 큐레이터가 답을 청할 때 (curatorAsk.js)
   ========================================================================== */
#speechBubble.ask {
  border-color: #e0603a;
  background: linear-gradient(135deg, #fffaf3 0%, #ffeedd 100%);
  animation: askBreath 2.4s ease-in-out infinite;
}
#speechBubble.ask .speech-bubble-text {
  font-size: 1.45rem;
  line-height: 1.5;
  font-weight: 800;
  color: #7a2e12;
  text-align: center;
  max-height: calc(1.5em * 3);
}
#speechBubble.ask .speech-bubble-name { color: #e0603a; background: rgba(224, 96, 58, 0.12); }
#speechBubble.ask .speech-bubble-name::after { content: ' · 당신 차례예요'; }
#speechBubble.ask .speech-bubble-arrow { color: #e0603a; }
@keyframes askBreath {
  0%, 100% { box-shadow: 0 10px 30px rgba(0,0,0,.3), 0 0 0 0 rgba(224, 96, 58, 0.45); }
  50%      { box-shadow: 0 10px 30px rgba(0,0,0,.3), 0 0 0 10px rgba(224, 96, 58, 0); }
}

/* 입력창 위 보기 버튼 줄 */
.ask-chips { margin: 0 0 10px; }
.ask-chips[hidden] { display: none !important; }
.ask-label { font-size: 1.12rem; font-weight: 800; color: #7a2e12; margin: 0 2px 8px; line-height: 1.45; }
.ask-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-btns button {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 8px 16px;
  font-size: 1.05rem; font-weight: 700; color: #4a2c00;
  background: #fffaf3; border: 2px solid #e0603a; border-radius: 14px;
  cursor: pointer; text-align: left; line-height: 1.35;
  transition: transform .12s ease, background .12s ease;
}
.ask-btns button:hover { background: #ffe7d6; transform: translateY(-1px); }
.ask-btns button:active { transform: translateY(1px); }
.ask-btns button b { color: #e0603a; font-size: 1.15rem; }
.ask-btns button.ask-edit { border-style: dashed; color: #7a5a3a; background: #fff; }
.ask-btns button.picked { background: #ffe7d6; }
.ask-dot { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); flex: none; }
.input-area.ask-active .message-input {
  border-color: #e0603a !important;
  box-shadow: 0 0 0 3px rgba(224, 96, 58, 0.18);
}

/* ==========================================================================
   🪞 스스로 바라보기 (selfView.js) — AI가 읽는 동안 먼저 나를 봄
   ========================================================================== */
.selfview {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px; overflow-y: auto;
  background: rgba(12, 10, 24, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.selfview[hidden] { display: none !important; }
.sv-card {
  width: min(760px, 100%);
  background: linear-gradient(160deg, #fffdf5 0%, #fff4e2 100%);
  color: #3d2600; border: 3px solid #b8860b; border-radius: 24px;
  padding: 26px 28px 22px; box-shadow: 0 24px 60px rgba(0,0,0,.4);
  font-family: -apple-system, 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  font-size: 17px; line-height: 1.6;
}
.sv-card h2 { font-size: 1.5rem; margin: 10px 0 4px; line-height: 1.35; }
.sv-card h3 { font-size: 1.08rem; margin: 0 0 10px; color: #7a4e00; }
.sv-card h3 em { font-style: normal; font-weight: 600; color: #b8860b; font-size: .9rem; margin-left: 6px; }
.sv-card section { margin-top: 20px; }
.sv-sub { color: #7a5a3a; margin: 0; }
.sv-status { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: #7a5a3a; background: rgba(184,134,11,.12); border-radius: 999px; padding: 4px 12px; }
.sv-status.ready { color: #fff; background: #e0603a; }
.sv-spin { width: 12px; height: 12px; border: 2px solid #b8860b; border-top-color: transparent; border-radius: 50%; animation: svSpin 0.9s linear infinite; }
@keyframes svSpin { to { transform: rotate(360deg); } }
.sv-tone { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px dashed rgba(184,134,11,.35); flex-wrap: wrap; }
.sv-tone:first-of-type { border-top: 0; }
.sv-tone > div { display: flex; gap: 6px; }
.sv-tone button, .sv-chips button, .sv-chips span {
  min-height: 44px; padding: 6px 16px; font-size: 1rem; font-weight: 700;
  border: 2px solid #d9b45a; background: #fff; color: #4a2c00; border-radius: 999px; cursor: pointer;
}
.sv-tone button.on, .sv-chips button.on, .sv-chips span.on { background: #e0603a; border-color: #e0603a; color: #fff; }
.sv-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sv-chips button:disabled { opacity: .4; cursor: default; }
.sv-chips.mine { margin-top: 14px; }
.sv-card input[type=text] {
  width: 100%; font-size: 1.05rem; padding: 12px 14px; border-radius: 12px;
  border: 2px solid #d9b45a; background: #fff; color: #3d2600;
}
.sv-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.sv-main, .sv-ghost { min-height: 50px; padding: 10px 22px; font-size: 1.08rem; font-weight: 800; border-radius: 14px; cursor: pointer; }
.sv-main { background: #e0603a; color: #fff; border: 2px solid #e0603a; }
.sv-main:disabled { opacity: .45; cursor: default; }
.sv-ghost { background: transparent; color: #7a5a3a; border: 2px solid #d9b45a; }
.sv-cmp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
@media (max-width: 640px) { .sv-cmp { grid-template-columns: 1fr; } .sv-card { padding: 20px 18px; } }
.sv-col { background: #fff; border: 2px solid #ecd9a8; border-radius: 16px; padding: 12px 14px; min-height: 110px; }
.sv-col h4 { margin: 0 0 8px; font-size: .95rem; color: #7a5a3a; }
.sv-col span { display: inline-block; margin: 0 6px 6px 0; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 1rem; }
.sv-col.both span { background: #d8f3ec; color: #145c4c; }
.sv-col.me span { background: #e3e7ff; color: #2c3a8f; }
.sv-col.ai span { background: #ffe7d6; color: #7a2e12; }
.sv-col p { margin: 0; color: #a08a6a; font-size: .95rem; }
.sv-hint { color: #7a5a3a; font-size: .95rem; margin: 12px 0 0; }

/* 🃏 감정카드 60장 (색 묶음) — 스스로 바라보기 */
.sv-picked { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 6px; }
.sv-slot {
  min-width: 132px; min-height: 64px; padding: 10px 16px; border-radius: 14px;
  border: 2px dashed #d9b45a; color: #b39a6a; font-size: 1rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; background: rgba(255,255,255,.6);
}
.sv-slot.on { border: 3px solid var(--g); background: var(--gs); color: #2d1d00; font-size: 1.25rem; cursor: pointer; }
.sv-group { margin-top: 14px !important; }
.sv-cardnote { font-size: .9rem; color: #7a7468; margin: 4px 0 2px; }
.sv-sym { font-size: .9em; margin-right: 2px; }
.sv-group h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px !important; }
.sv-group h3 i { width: 14px; height: 14px; border-radius: 50%; background: var(--g); display: inline-block; }
.sv-group .sv-chips button { border-color: var(--gs); background: #fff; min-height: 42px; padding: 5px 14px; }
.sv-group .sv-chips button:hover:not(:disabled) { border-color: var(--g); }
.sv-group .sv-chips button.on { background: var(--g); border-color: var(--g); color: #fff; }
.sv-card-chip {
  display: inline-block; margin: 0 6px 6px 0; padding: 4px 13px; border-radius: 999px;
  background: var(--gs); border: 2px solid var(--g); color: #2d1d00; font-weight: 800; font-size: 1rem;
}
.sv-card-chip.big { font-size: 1.2rem; padding: 8px 18px; }
.sv-col .sv-card-chip { margin: 0 6px 6px 0; }
.sv-kin { margin: 12px 0 0; color: #5a4020; font-size: .98rem; line-height: 2; }
.sv-kin small { color: #8a7050; }


/* 🪞 스스로 바라보기: 화면 위에 떠 있는 창 (무대가 보이도록 배경을 덮지 않음) */
.selfview {
  inset: auto !important; left: 50% !important; top: 50% !important;
  transform: translate(-50%, -50%);
  width: min(740px, calc(100vw - 24px)); max-height: 88vh;
  padding: 0 !important; background: none !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  overflow: visible !important; display: block !important;
}
.selfview[hidden] { display: none !important; }
.selfview .sv-card {
  position: relative; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(184,134,11,.25);
}
.selfview.pop .sv-card, .selfview.pop .sv-tab { animation: svPop .35s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes svPop { from { opacity: 0; transform: scale(.88) translateY(14px); } to { opacity: 1; transform: none; } }
.sv-collapse {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  min-height: 38px; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  font-size: .95rem; font-weight: 700; color: #7a5a3a; background: #fff; border: 2px solid #d9b45a;
}
.sv-collapse:hover { background: #fff4e2; }
/* 접힌 상태: 아래쪽 작은 탭 */
.selfview.collapsed { top: auto !important; bottom: 18px !important; transform: translateX(-50%); width: auto; }
.sv-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 56px; padding: 8px 26px; border-radius: 18px; cursor: pointer;
  background: linear-gradient(160deg, #fffdf5, #fff4e2); border: 3px solid #b8860b; color: #3d2600;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); font-family: inherit;
}
.sv-tab b { font-size: 1.1rem; }
.sv-tab span { font-size: .88rem; color: #7a5a3a; }
.sv-tab.ready { border-color: #e0603a; animation: askBreath 2.4s ease-in-out infinite; }
.sv-tab.ready span { color: #c2410c; font-weight: 700; }
/* 카드를 고르는 동안 도착한 AI 답은 채팅창에서 잠시 가려 둠 */
.sv-hold-note { color: #8a7050; font-style: italic; }

/* 🪞 스스로 바라보기: 가로로 넓혀 한 화면에 카드 60장이 다 보이게 */
.selfview { width: min(1180px, calc(100vw - 24px)); }
.selfview .sv-card { padding: 18px 26px 16px; }
.selfview .sv-card h2 { font-size: 1.4rem; margin: 8px 0 2px; }
.selfview .sv-picked { margin: 12px 0 4px; }
.selfview .sv-slot { min-height: 46px; min-width: 150px; padding: 6px 16px; }
.selfview .sv-group { display: grid; grid-template-columns: 104px 1fr; align-items: start; gap: 10px; margin-top: 8px !important; }
.selfview .sv-group h3 { margin: 0 !important; padding-top: 9px; font-size: 1.02rem; }
.selfview .sv-group .sv-chips { gap: 6px; }
.selfview .sv-group .sv-chips button { min-height: 38px; padding: 4px 13px; font-size: .98rem; }
.selfview .sv-foot { margin-top: 16px; }
@media (max-width: 760px) {
  .selfview .sv-group { grid-template-columns: 1fr; gap: 6px; }
  .selfview .sv-group h3 { padding-top: 0; }
}

/* 🪞 견주어 보기: 내가 본 카드 한 칸 · AI가 본 카드 한 칸 + 질문 */
.sv-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 640px) { .sv-two { grid-template-columns: 1fr; } }
.sv-two .sv-col { min-height: 0; padding: 14px 16px; }
.sv-two .sv-col h4 { font-size: 1rem; margin-bottom: 10px; }
.sv-two .sv-col.me { border-color: #b9c4ee; background: #f7f8ff; }
.sv-two .sv-col.ai { border-color: #f2c2a8; background: #fff8f3; }
.sv-two .sv-card-chip { font-size: 1.15rem; padding: 6px 16px; background: var(--gs) !important; color: #2d1d00 !important; border: 2px solid var(--g); margin: 0 8px 8px 0; }
.sv-card-chip.same { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #2ea36b; }
.sv-same-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #2ea36b; vertical-align: -2px; margin-right: 6px; }
.sv-question { margin: 18px 0 0; padding: 14px 18px; border-radius: 14px; background: #fff; border: 2px dashed #e0603a; color: #7a2e12; font-size: 1.3rem; font-weight: 800; line-height: 1.5; text-align: center; }

/* 🪞 견주어 보기·대기 화면은 내용이 적으니 창을 좁게 (카드 고르기는 60장이 다 보이도록 넓게 유지) */
.selfview.stage-compare:not(.collapsed) { width: min(860px, calc(100vw - 24px)); }
.selfview.stage-compare .sv-question { font-size: 1.22rem; }

/* 🪞 견주어 보기: 카드와 제목을 가운데 정렬 */
.sv-two .sv-col { text-align: center; }
.sv-two .sv-col > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sv-two .sv-card-chip { margin: 0 !important; }

/* 🙋 질문 창 (curatorAsk.js) — 스스로 바라보기와 같은 떠 있는 창 */
.askview { z-index: 3001; }
.ask-card .ask-q { font-size: 1.5rem !important; line-height: 1.45; margin: 12px 0 14px !important; color: #3d2600; }
.ask-list { display: flex; flex-direction: column; gap: 10px; }
.ask-list button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 58px; padding: 10px 18px; border-radius: 16px; cursor: pointer;
  font-size: 1.15rem; font-weight: 700; line-height: 1.4; color: #3d2600;
  background: #fff; border: 2px solid #e8a77f; transition: background .12s, transform .12s;
}
.ask-list button:hover { background: #fff1e6; transform: translateY(-1px); }
.ask-list button b { color: #e0603a; font-size: 1.3rem; flex: none; }
.ask-list button.ask-edit { border-style: dashed; color: #7a5a3a; }
.ask-list .ask-dot { width: 26px; height: 26px; }
/* 색 질문처럼 보기가 많으면 두 줄 배치 */
.ask-list:has(> button:nth-child(7)) { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.ask-list:has(> button:nth-child(7)) button { min-height: 52px; padding: 8px 14px; white-space: nowrap; }
.ask-foot { margin: 14px 0 0; color: #8a7050; font-size: .95rem; text-align: center; }
.ask-tab b { font-size: 1.1rem; }
/* 채팅창 답 맨 끝의 [다 읽었어요] 버튼 */
.ask-read-btn {
  display: block; margin: 14px auto 4px; min-height: 48px; padding: 10px 22px; border-radius: 14px; cursor: pointer;
  font-size: 1.05rem; font-weight: 800; color: #fff; background: #e0603a; border: 0; white-space: nowrap; max-width: 100%;
  box-shadow: 0 6px 16px rgba(224, 96, 58, .35); animation: askBreath 2.4s ease-in-out infinite;
}
.ask-read-btn:hover { background: #c94f2b; }
/* 이전의 입력창 위 보기 줄은 쓰지 않음 */
#askChips { display: none !important; }

/* 🎨 색 질문: 세 가지까지 고르기 */
.ask-multi-hint { margin: -4px 0 12px; color: #7a5a3a; font-size: 1.02rem; }
.ask-multi-hint b { color: #c2410c; }
.ask-list button.on { background: #ffe1cf; border-color: #e0603a; box-shadow: 0 0 0 2px #e0603a inset; }
.ask-list button:disabled { opacity: .4; cursor: default; transform: none; }
.ask-send-row { display: flex; justify-content: flex-end; margin-top: 14px; }

/* 💬 큐레이터 답: 마크다운 기호 없이 읽기 좋게 (curatorFormat.js) */
.message-content.curator-rich { white-space: normal !important; line-height: 1.75; font-size: 1rem; }
.message-content.curator-rich > * { margin: 0; }
.message-content.curator-rich > * + * { margin-top: 0.7rem; }
.curator-rich p { color: #e5e7eb; }
.curator-rich .cr-h {
  margin-top: 1.1rem !important; font-size: 0.9rem; font-weight: 800; letter-spacing: 0.02em;
  color: #fbbf8a; display: flex; align-items: center; gap: 8px;
}
.curator-rich .cr-h::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #e0603a; }
.curator-rich > .cr-h:first-child { margin-top: 0.1rem !important; }
.curator-rich .cr-hanmadi {
  font-size: 1.12rem; font-weight: 700; line-height: 1.65; color: #fff;
  padding: 0.7rem 0.9rem; border-left: 3px solid #e0603a; background: rgba(224, 96, 58, 0.12); border-radius: 0 10px 10px 0;
}
.curator-rich .cr-cards { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.curator-rich .cr-label { font-size: 0.82rem; color: #a1a1b5; margin-right: 4px; }
.curator-rich .cr-card { display: inline-block; padding: 3px 12px; border-radius: 999px; font-weight: 800; font-size: 0.95rem; background: var(--gs, #eee); border: 2px solid var(--g, #999); color: #2d1d00; }
.curator-rich .cr-list { list-style: none; padding: 0; }
.curator-rich .cr-list li { padding: 0.45rem 0; border-top: 1px dashed rgba(255, 255, 255, 0.12); }
.curator-rich .cr-list li:first-child { border-top: 0; }
.curator-rich .cr-no { display: inline-block; font-size: 0.78rem; font-weight: 800; color: #fbbf8a; border: 1px solid rgba(251, 191, 138, 0.5); border-radius: 6px; padding: 0 6px; margin-right: 4px; }
.curator-rich q { color: #fff; font-weight: 600; quotes: '“' '”'; }
.curator-rich blockquote { border-left: 3px solid #818cf8; background: rgba(129, 140, 248, 0.1); padding: 0.6rem 0.8rem; border-radius: 0 8px 8px 0; color: #e0e7ff; font-style: italic; }
.curator-rich .cr-sofar { font-size: 0.85rem; color: #a1a1b5; }
.curator-rich .cr-material { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(251, 191, 138, 0.35); border-radius: 12px; padding: 0.7rem 0.9rem; }
.curator-rich .cr-material-title { font-weight: 800; color: #fbbf8a; margin-bottom: 0.4rem; }
.curator-rich .cr-mrow { display: flex; gap: 10px; padding: 0.25rem 0; border-top: 1px dashed rgba(255, 255, 255, 0.1); }
.curator-rich .cr-mrow:first-of-type { border-top: 0; }
.curator-rich .cr-mrow span { flex: none; min-width: 4.6em; color: #a1a1b5; font-size: 0.9rem; }
.curator-rich .cr-mrow b { color: #fff; font-weight: 700; }

/* 📄 [내 가면 재료] 아래의 수업 리포트 버튼 */
.curator-rich .class-report-btn {
  display: block; width: 100%; margin-top: 0.9rem !important; padding: 0.8rem 1rem;
  font: inherit; font-size: 1.02rem; font-weight: 800; letter-spacing: 0.02em;
  color: #0f2f2b; background: #3fd0b8; border: 0; border-radius: 12px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(63, 208, 184, 0.28);
}
.curator-rich .class-report-btn:hover { background: #5fe0ca; }
.curator-rich .class-report-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* 🎭 견주어 보기: 내가 고른 카드의 탈 | AI가 본 카드의 탈 — 좌우 반반 */
.selfview.stage-compare:not(.collapsed) { width: min(1040px, calc(100vw - 24px)); }
.sv-masks { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
@media (max-width: 640px) { .sv-masks { grid-template-columns: 1fr; } }
.sv-mask { margin: 0; border-radius: 18px; padding: 12px 12px 14px; text-align: center; border: 2px solid #ecd9a8; background: #fffdf8; display: flex; flex-direction: column; gap: 10px; }
.sv-mask.me { border-color: #b9c4ee; background: #f7f8ff; }
.sv-mask.ai { border-color: #f2c2a8; background: #fff8f3; }
.sv-mask figcaption { font-size: 1.1rem; font-weight: 800; color: #5a3e22; }
.sv-mask-pic { aspect-ratio: 1 / 1; width: min(100%, 40vh); margin: 0 auto; border-radius: 14px; overflow: hidden; background: #1b1512; display: flex; align-items: center; justify-content: center; }
.sv-mask-pic img { width: 100%; height: 100%; object-fit: cover; display: block; animation: svFade .6s ease; }
@keyframes svFade { from { opacity: 0; } to { opacity: 1; } }
.sv-mask-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #f3e6cf; font-size: 1.05rem; font-weight: 700; line-height: 1.5; padding: 16px; }
.sv-mask-wait small { font-weight: 500; opacity: .8; }
.sv-mask-wait .sv-spin { width: 28px; height: 28px; border-width: 3px; border-color: #e8c06a; border-top-color: transparent; }
.sv-mask-wait.err { color: #ffd3c2; }
.sv-mask-wait .sv-ghost { min-height: 40px; font-size: .95rem; }
.sv-mask-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sv-mask-chips .sv-card-chip { font-size: 1.12rem; padding: 6px 16px; background: var(--gs) !important; color: #2d1d00 !important; border: 2px solid var(--g); margin: 0; }
.sv-foot.center { justify-content: center; }
.sv-main.sv-why { font-size: 1.22rem; padding: 14px 26px; min-height: 58px; line-height: 1.4; max-width: 100%; white-space: normal; }
.sv-main.sv-why b { margin-left: 6px; }
.sv-draw { margin: 18px 0 0; text-align: center; font-size: 1.25rem; font-weight: 800; color: #5a3e22; }
.sv-draw + .sv-foot { margin-top: 12px; }

/* ===== 🌸 감정 꽃 (견주어 보기 · emotionFlower.js · 수국, 움직임은 JS) ===== */
.sv-flower-pic { background: #f7f5f0 !important; border: 1px solid #ecd9a8; box-shadow: inset 0 0 18px rgba(160, 120, 60, .12); }
.sv-flower-pic { width: min(100%, 34vh) !important; }
.sv-flower-pic .sv-mask-wait { color: #8a7050; }
.emotion-flower { width: 100%; height: 100%; display: block; }
.sv-flower-key { margin: 10px 0 0; text-align: center; font-size: .92rem; color: #8a7050; line-height: 1.6; }

/* 🎨 내 감정, 무엇으로 표현할까? (꽃 견주기 다음 · expressPrompt.js) */
.sv-subjects { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 14px 0 6px; }
@media (max-width: 760px) { .sv-subjects { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sv-subjects button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; font: inherit; font-size: 1.05rem; font-weight: 800;
  color: #4a3420; background: #fff; border: 2px solid #e6dccb; border-radius: 14px; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; }
.sv-subjects button i { font-style: normal; font-size: 2rem; line-height: 1; }
.sv-subjects button:hover { border-color: #c9a879; transform: translateY(-2px); }
.sv-subjects button.on { border-color: #e0603a; background: #fff3ea; box-shadow: 0 0 0 2px #e0603a inset; }
.sv-q { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0 0; }
.sv-q > b { font-size: 1.05rem; color: #4a3420; }
.sv-q-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.sv-q-opts button { font: inherit; font-size: 1rem; font-weight: 700; padding: 7px 16px; border-radius: 999px; border: 2px solid #e6dccb; background: #fff; color: #4a3420; cursor: pointer; }
.sv-q-opts button.on { border-color: #e0603a; background: #fff3ea; }
.sv-prompts { align-items: start; }
.sv-prompt { margin: 0; background: #fffdf8; border: 1.5px solid #e6dccb; border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sv-prompt.ai { background: #f8f7ff; border-color: #d9d4f2; }
.sv-prompt figcaption { font-weight: 800; font-size: 1.02rem; color: #4a3420; }
.sv-prompt-empty { margin: 8px 0; color: #8a7a66; }
.sv-prompt-map { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .95rem; color: #4a3420; line-height: 1.5; }
.sv-prompt-map i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.sv-prompt-box { background: #fff; border: 1px solid #ece3d3; border-radius: 10px; padding: 8px 10px; }
.sv-prompt-box.en { background: #fbfaf6; }
.sv-prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.sv-prompt-head b { font-size: .85rem; color: #8a7050; }
.sv-prompt-box p { margin: 0; font-size: .95rem; line-height: 1.6; color: #3b2a1a; user-select: text; word-break: keep-all; overflow-wrap: anywhere; }
.sv-prompt-box.en p { font-size: .88rem; color: #5a4a36; }
.sv-copy { padding: 4px 12px !important; font-size: .85rem !important; min-height: 0 !important; }
.sv-foot.center .sv-ghost + .sv-main { margin-left: 10px; }
