@font-face {
  font-family: "Isamanru";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-10@1.0/GongGothicLight.woff")
    format("woff");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Isamanru";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-10@1.0/GongGothicMedium.woff")
    format("woff");
  font-weight: normal;
  font-display: swap;
}

@font-face {
  font-family: "Isamanru";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-10@1.0/GongGothicBold.woff")
    format("woff");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-1Thin.woff")
    format("woff");
  font-weight: 100;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-2ExtraLight.woff")
    format("woff");
  font-weight: 200;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-3Light.woff")
    format("woff");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-4Regular.woff")
    format("woff");
  font-weight: normal;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-5Medium.woff")
    format("woff");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-6Bold.woff")
    format("woff");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-7ExtraBold.woff")
    format("woff");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-8Heavy.woff")
    format("woff");
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "Escoredream";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-9Black.woff")
    format("woff");
  font-weight: 900;
  font-display: swap;
}

/* 말풍선 기본 스타일 */
.speech-bubble {
  position: relative;
  padding: 15px 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  line-height: 1.5;
  display: block;
  width: fit-content;
  max-width: 60%;
  word-wrap: break-word;
  white-space: normal;
  margin-bottom: 5px;
  text-align: justify;
  font-family: kopub돋움L;
}

.speech-bubble:focus {
  outline: none;
}

.speech-bubble-you {
  background: #292929;
  color: #fff;
  border-radius: 0px 20px 20px 20px;
  margin-left: 15px;
}

/* .speech-bubble-you:after {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 9px solid transparent;
  border-right-color: #292929;
} */

.speech-bubble-me {
  background: #f0f0f0;
  color: #333;
  border-radius: 20px 0px 20px 20px;
  margin-left: auto;
  margin-right: 15px;
}

/* .speech-bubble-me:after {
  content: "";
  position: absolute;
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 9px solid transparent;
  border-left-color: #f0f0f0;
} */

.speech-bubble-you + .speech-bubble-me,
.speech-bubble-me + .speech-bubble-you {
  margin-top: 20px;
}

/* -------------------------------- */

/* 페이지 전체 스타일 */
body {
  background: #f0f2f5;
  background-image: url("/src/snow-background.jpg");
  background-size: cover;
  backdrop-filter: blur(3px);
  font-family: "Escoredream", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  color: #333;
  margin: 0;
  padding: 20px;
}

body::-webkit-scrollbar {
  width: 8px;
}

body::-webkit-scrollbar-thumb {
  background-color: rgba(149, 174, 205, 0.399);
  border-radius: 4px;
}

body::-webkit-scrollbar-button {
  display: none;
}

h3 {
  text-align: center;
  font-family: "Isamanru";
  font-size: 22px;
  font-weight: 300;
  margin-top: 5px;
  margin-bottom: 10px;
  color: #302d39;
}

textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid #ccc;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
}

textarea::-webkit-scrollbar {
  display: none;
}

textarea:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 8px rgba(0, 122, 255, 0.3);
}

button {
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  background-color: #007aff;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

button:hover {
  background-color: #005bb5;
}

#copyright {
  font-family: "Escoredream";
  font-size: 14px;
  font-weight: 300;
  justify-self: center;
  color: white;
  margin-bottom: 4px;
}

.section-container.preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

#preview {
  min-height: 200px;
  max-height: 1100px;
  padding: 15px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  overflow-x: hidden;
}

#preview::-webkit-scrollbar {
  width: 8px;
}

#preview::-webkit-scrollbar-thumb {
  background-color: rgba(149, 174, 205, 0.399);
  border-radius: 4px;
}

#preview::-webkit-scrollbar-button {
  display: none;
}

#preview-reset {
  width: 110px;
  height: 35px;
  margin-top: 3px;
  font-size: 13px;
  padding: 0;
  padding-top: 2px;
}

.body-container {
  width: 90%;
}

.color-settings {
  display: grid;
  grid-template-columns: 45fr 50fr;
  gap: 10px 30px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.color-settings label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.color-settings input {
  margin-left: 3px;
  max-width: 25px;
  border-radius: 5px;
  border: solid 1px gray;
}

.code-container {
  position: relative;
  width: 100%;
  max-width: 650px;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #007aff;
  color: white;
  font-size: 12px;
  cursor: pointer;
  z-index: 10;
}

.copy-btn:hover {
  background: #005bb5;
}

#output {
  width: 100%;
  min-height: 150px;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid #ccc;
  font-family: monospace;
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
  background: #f7f7f7;
}

.container {
  display: flex;
  height: auto;
  gap: 100px;
  flex-wrap: wrap;
  padding: 20px 100px;
  align-items: top;
  justify-content: center;
}

.left-panel {
  flex: 1;
  max-width: 500px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.section-container {
  display: flex;
  max-width: 500px;
  min-width: 480px;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border: solid 2px white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.right-panel {
  flex: 1;
  max-width: 600px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* 파일 업로드 섹션 */
.csv-upload-section {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.csv-upload-section input[type="file"] {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  flex: 1;
}

#bgimg-reset {
  width: 25px;
  height: 25px;
  padding: 4px;
  font-size: 12px;
}

/* 캐릭터 선택 섹션 */
.character-selection {
  display: none;
  grid-template-columns: auto;
  grid-template-areas:
    "a b"
    "c c";
  gap: 15px;
  align-items: top;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.character-selection label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
  font-weight: 600;
}

.character-selection select {
  width: 140px;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  min-width: 150px;
  cursor: pointer;
}

.character-selection select:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 8px rgba(0, 122, 255, 0.3);
}

.character-selection input[type="color"] {
  width: 25px !important;
  border-radius: 5px;
  border: solid 1px gray;
}

#meCharacterContainer {
  display: none;
  max-width: 180px;
  grid-area: a;
}

#youCharactersContainer {
  display: none;
  min-width: 280px;
  grid-area: b;
}

.character-selection button {
  max-width: 150px;
  grid-area: c;
  margin-top: auto;
  justify-self: center;
  align-self: center;
}

/* 전체 스타일 편집 섹션 */
.global-style-container {
  display: grid;
  row-gap: 15px;
}

#globalBgImage {
  width: 80px !important;
}

.style-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.style-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
}

.style-row label .label-text {
  display: inline-block;
  width: 83px;
}

.style-row input[type="color"] {
  width: 50px;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
}

.style-row input[type="range"] {
  width: 100px;
  cursor: pointer;
}

.style-row input[type="text"] {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
}

.style-row select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  cursor: pointer;
}

#reset,
#setting-reset {
  width: 80px;
  height: 35px;
  margin-top: 3px;
  font-size: 13px;
  padding: 0;
  padding-top: 2px;
  justify-self: center;
}

/* 수동 입력 스타일 */
.meTextContainer,
.youTextContainer {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas:
    "a . ."
    "b b c";
  gap: 8px;
}

.meTextContainer button,
.youTextContainer button {
  grid-area: c;
}
#meName,
#youName {
  max-width: 200px;
  min-height: 5px;
  grid-area: a;
  padding: 5px 10px;
  align-content: center;
  resize: none;
}

#meText,
#youText {
  min-height: 100px;
  grid-area: b;
}

/* 컨텍스트 메뉴 커스텀 스타일 */
.bubble-context-menu-theme {
  background: white;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 180px;
  overflow: hidden;
}

.bubble-context-menu-theme .context-menu-item {
  padding: 10px 20px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: background 0.2s;
}

.bubble-context-menu-theme .context-menu-item:hover {
  background: #f0f0f0;
}

/* 프로필 사진 원형 */
.profile-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-top: 5px;
  background-color: #e0e0e0;
  cursor: pointer;
  transition: opacity 0.2s;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.profile-circle:hover {
  opacity: 0.8;
}

/* 프로필 컨텍스트 메뉴 */
.profile-context-menu {
  position: fixed;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  min-width: 150px;
  padding: 4px 0;
}

.profile-context-menu-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s;
}

.profile-context-menu-item:hover {
  background-color: #f0f0f0;
}

/* 메시지 컨테이너 (프로필 + 말풍선) - Grid 레이아웃 */

/* 드래그할 때 생기는 자리 */
.drag-placeholder {
  height: 48px;
  border: 2px dashed #bbb;
  border-radius: 10px;
  margin: 8px 0;
  background: rgba(0, 0, 0, 0.05);
}

/* 드래그 중인 요소 스타일 */
.dragging {
  opacity: 0.4 !important;
  transform: scale(0.98);
}

.message-container.show-profile {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 5px 10px;
  padding-left: 15px;
}
.message-container {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto;
  gap: 0px 10px;
  padding-left: 15px;
  transition: transform 150ms ease, opacity 150ms ease;
}

.message-container.me {
  grid-template-columns: 1fr auto;
  padding-left: 0;
  padding-right: 15px;
}

.message-container .character-name {
  height: 0;
}
.message-container.show-profile .character-name {
  height: auto;
}

/* 프로필 이미지 */
.profile-image {
  grid-row: 1 / 3;
  grid-column: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e0e0e0;
  object-fit: cover;
  align-self: start;
}

.message-container.me .profile-image {
  grid-column: 2;
}

/* 캐릭터 이름 */
.character-name {
  grid-row: 1;
  grid-column: 2;
  font-size: 14.5px;
  color: #666;
  font-family: "";
  font-weight: 500;
  white-space: nowrap;
  align-self: center;
}

.message-container.me .character-name {
  grid-column: 1;
  text-align: right;
}

/* 말풍선 */
.message-container .speech-bubble {
  grid-row: 2;
  grid-column: 2;
}

.message-container.me .speech-bubble {
  grid-column: 1;
  justify-self: end;
}

/* 연속 메시지 간격 조정 */
.message-container + .message-container {
  margin-top: 2px;
}

.message-container.show-profile {
  margin-top: 15px;
}

/* 비밀번호 오버레이 */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  animation: fadeIn 0.3s ease;
}

.password-overlay.hidden {
  display: none;
}

.password-modal {
  background: white;
  padding: 40px 50px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
  min-width: 350px;
  animation: slideUp 0.3s ease;
}

.password-modal h2 {
  font-family: "Isamanru", sans-serif;
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 25px;
  color: #302d39;
}

.password-modal input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  font-family: "Escoredream", sans-serif;
  margin-bottom: 20px;
  box-sizing: border-box;
  transition: border-color 0.3s;
}

.password-modal input[type="password"]:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.password-modal button {
  width: 100%;
  padding: 14px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
}

.password-modal button:hover {
  background: #005bb5;
}

.password-error {
  color: #ff3b30;
  font-size: 14px;
  margin-top: 15px;
  min-height: 20px;
  font-family: "Escoredream", sans-serif;
}

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

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

/* 모바일 대응 */
@media (max-width: 1100px) {
  .container {
    flex-direction: column;
    gap: 30px;
    padding: 10px;
    align-items: center;
  }

  .left-panel,
  .right-panel {
    max-width: 100%;
    min-width: unset;
  }
}

/* 더 작은 화면 */
@media (max-width: 600px) {
  body {
    padding: 10px;
    background-size: cover;
  }

  .container {
    flex-direction: column;
    gap: 30px;
    padding: 10px;
    align-items: center;
  }

  .left-panel,
  .right-panel {
    width: 100%;
    min-width: unset;
    align-items: center;
  }

  .section-container {
    min-width: unset;
    width: 80%;
    padding: 12px;
  }

  .color-settings label {
    font-size: 11px;
    word-break: keep-all;
  }

  .speech-bubble {
    max-width: 90%;
    padding: 12px 15px;
    font-size: 14px;
  }

  h3 {
    font-size: 18px;
  }

  textarea {
    font-size: 13px;
  }

  .style-row {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-left: 30px;
  }

  #preview {
    max-height: 800px;
  }

  .character-selection {
    grid-template-columns: 1fr;
    grid-template-areas:
      "a"
      "b"
      "c";
  }

  #profile_meCharacter_auto {
    margin-right: 155px;
  }

  .options-row {
    transform: translateX(-195px);
  }

  #meCharacterContainer {
    display: flex !important;
  }

  #meCharacterContainer label {
    margin-left: 45px;
  }

  .character-selection select {
    width: 100%;
  }
}
