@font-face {
  font-family: 'ActofFont';
  src: url('https://cdn.jsdelivr.net/gh/fromcheon121-create/my-fonts@main/DungGeunMo.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: none; 
  -ms-overflow-style: none; 
}

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

html { background-color: #F9F9F7; overflow: hidden; }

body {
  background-color: transparent;
  color: #333333;
  font-family: 'ActofFont', monospace;
  position: absolute;
  top: 24px; bottom: 150px; left: 0; right: 0;
  overflow-y: auto; overflow-x: auto; 
  scroll-behavior: smooth; 
  scroll-padding-bottom: 60px; 
}

.container {
  width: 100%;
  max-width: 1280px; min-width: 1010px; min-height: 700px; 
  margin: 0 auto; 
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 630px minmax(190px, 1fr); 
  padding-bottom: 100px; 
  align-content: start; 
}

.main-header, .memo-area { grid-column: 2; }

.main-header {
  width: 100%; margin-top: 200px; opacity: 1; visibility: visible;
  max-height: 100px; transition: all 0.4s ease;
}
.brand-title { font-size: 24px; font-weight: normal; color: #222; }

.memo-area {
  position: relative; width: 100%; display: flex; flex-direction: column;
  transition: margin-top 0.4s ease;
}

.date-stamp {
  position: absolute; top: 0; right: -325px; width: 325px; 
  padding-left: 20px; text-align: left; font-size: 14px;
  color: #ff4a4a; z-index: 10; opacity: 0; visibility: hidden; transition: opacity 0.4s ease;
}

.memo-input-container { width: 100%; display: flex; flex-direction: column; }

/* ✨ 제목과 본문 투명 먹지 배경 세팅 */
.trace-bg, .trace-title-bg {
  position: absolute;
  top: 0; left: 0; right: 0;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.3;
  color: rgba(51, 51, 51, 0.4); 
  pointer-events: none;  
  z-index: 1; 
}
.trace-bg { white-space: pre-wrap; }
.trace-title-bg { white-space: pre; }

.title-input {
  position: relative;
  z-index: 2;
  width: 100%; background: transparent; border: none; outline: none;
  font-family: inherit; font-size: 14px; color: #222;
  margin-bottom: 0; 
  caret-color: #ff4a4a; 
}

.body-input {
  position: relative;
  z-index: 2;
  width: 100%; min-height: 450px; background: transparent; border: none; outline: none; 
  font-family: inherit; font-size: 14px; line-height: 1.3; color: #333333;
  display: none; caret-color: #ff4a4a; cursor: text;
}
.body-input[contenteditable]:empty::before { content: attr(data-placeholder); color: #888888; pointer-events: none; }

/* ✨ 오타 발생 시 마크 블록 처리 (글자 숨김) */
.trace-typo {
  color: #C4C4C4 !important; 
  background-color: #C4C4C4 !important; 
  opacity: 1 !important; 
}

.typing-mode .main-header { opacity: 0; visibility: hidden; max-height: 0; margin-top: 0; }
.typing-mode .memo-area { margin-top: 150px; display: flex; flex-direction: column; }
.typing-mode .edit-btn-container, .typing-mode .date-stamp {
  position: sticky; top: 0; height: 0; left: auto; right: auto;
  opacity: 1; visibility: visible; z-index: 21;
}
.typing-mode .edit-btn-container { order: -2; transform: translateX(-325px); }
.typing-mode .date-stamp {
  order: -1; transform: translateX(630px); position: absolute; top: 80px !important; padding-top: 0; 
}
.typing-mode .memo-input-container { order: 1; }
.typing-mode .body-input { display: block; }

.edit-btn-container {
  position: absolute; top: 0; left: -325px; width: 325px; padding-right: 20px; 
  text-align: right; z-index: 10; opacity: 0; visibility: hidden; transition: opacity 0.4s ease;
}
.text-btn {
  background: transparent; border: none; font-family: inherit; font-size: 14px;
  color: #888888; cursor: pointer; transition: color 0.2s ease;
}
.text-btn:hover { color: #5F89FF; }
.typing-mode .edit-btn-container { opacity: 1; visibility: visible; }

.edit-menu {
  position: absolute; top: 80px; right: 20px; display: flex; flex-direction: column; gap: 12px; 
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-10px); transition: all 0.3s ease;
}
.menu-row { display: flex; justify-content: flex-end; gap: 10px; transition: margin-bottom 0.2s ease; }
.menu-row.expand { margin-bottom: 25px; }

/* ✨ 에디트 메뉴 강제 복구! */
.edit-btn-container.show-menu .edit-menu { 
  opacity: 1 !important; 
  visibility: visible !important; 
  pointer-events: auto !important; 
  transform: translateY(0) !important; 
}

.color-wrapper { position: relative; display: flex; align-items: center; }
.color-palette {
  position: absolute; top: 28px; right: 0; display: flex; gap: 8px; 
  opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.2s ease;
}
.color-palette.show { opacity: 1; visibility: visible; transform: translateY(0); }
.color-chip { width: 12px; height: 12px; border: none; cursor: pointer; transition: transform 0.1s ease; }
.color-chip:hover { transform: scale(1.2); }
.color-chip.blue { background-color: #5F89FF; }
.color-chip.red { background-color: #FF5659; }
.color-chip.black { background-color: #333333; }

.size-wrapper { position: relative; display: flex; align-items: center; }
.size-palette {
  position: absolute; top: 26px; right: -8px; display: flex; gap: 8px; align-items: flex-end; 
  opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.2s ease;
}
.size-palette.show { opacity: 1; visibility: visible; transform: translateY(0); }
.size-chip { background-color: #888888; border: none; cursor: pointer; transition: transform 0.1s ease, background-color 0.2s ease; }
.size-chip:hover { background-color: #5F89FF; transform: scale(1.1); }
.size-chip.small { width: 10px; height: 10px; }
.size-chip.medium { width: 12px; height: 12px; }
.size-chip.large { width: 14px; height: 14px; }
.menu-row.expand-size { margin-bottom: 30px; }
.body-input font[size="1"] { font-size: 12px; position: relative; top: -3px; }
.body-input font[size="2"] { font-size: 14px; } 
.body-input font[size="3"] { font-size: 16px; }

.mark-wrapper { position: relative; display: inline-block; }
.mark-palette {
  position: absolute; top: 28px; left: 50%; display: flex; opacity: 0; visibility: hidden;
  transform: translate(-50%, -5px); transition: all 0.2s ease;
}
.mark-palette.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.mark-chip { width: 24px; height: 12px; background-color: #D9D9D9; border: none; cursor: pointer; transition: transform 0.1s ease, background-color 0.2s ease; }
.mark-chip:hover { background-color: #5F89FF; transform: scale(1.1); }
.menu-row.expand-mark { margin-bottom: 30px; }
.menu-row.expand, .menu-row.expand-size, .menu-row.expand-mark { margin-bottom: 28px !important; }
.color-wrapper, .size-wrapper, .mark-wrapper { display: inline-block; vertical-align: top; }

sup.rewrite-mark {
  display: inline-block; vertical-align: baseline; position: relative; top: -8px; 
  color: #FF5659; font-size: 14px; margin-left: 2px; font-family: inherit; font-weight: normal; line-height: 1; cursor: pointer;
}
.rewrite-wrapper { position: relative; display: inline-flex; align-items: center; vertical-align: top; }
.rewrite-palette {
  position: absolute; top: 24px; left: 50%; transform: translate(-50%, -5px); display: flex; opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.rewrite-palette.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.rewrite-chip { color: #FF5659; font-size: 14px; background: transparent; border: none; cursor: pointer; font-family: inherit !important; font-weight: normal !important; }
.menu-row.expand-rewrite { margin-bottom: 28px !important; }
.rewrite-popup {
  position: absolute; width: 170px; min-height: 120px; height: auto; background-color: #D0EAB5; 
  padding: 8px 10px 32px 10px; box-sizing: border-box; opacity: 0; visibility: hidden; z-index: 1000;
}
.rewrite-popup.show { opacity: 1; visibility: visible; }
.rewrite-close {
  position: absolute; bottom: 6px; right: 12px; background: transparent; border: none; font-family: inherit; font-size: 13px; color: #FFFFFF; cursor: pointer; padding: 0;
}
.rewrite-textarea {
  width: 100%; height: 80px; min-height: 80px; overflow: hidden; background: transparent; border: none; outline: none; resize: none; font-family: inherit; font-size: 12px; color: #333; line-height: 1.4;
}
.rewrite-time-display {
  position: absolute; bottom: 6px; left: 10px; right: auto; font-family: inherit; font-size: 11px; color: #FFFFFF; opacity: 0.9; pointer-events: none; 
}

.timestamp-wrapper { position: relative; display: inline-flex; align-items: center; vertical-align: top; }
.timestamp-palette {
  position: absolute; top: 24px; left: 50%; transform: translate(-50%, -5px); display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.timestamp-palette.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.menu-row.expand-timestamp { margin-bottom: 56px !important; }
.ts-btn { background: transparent; border: none; font-family: inherit; font-size: 14px; color: #888888; cursor: pointer; padding: 2px 6px; transition: all 0.2s ease; }
.ts-btn.active-s, .ts-btn.active-rw { background-color: #D9D9D9; color: #333333; }
#timestamp-container { display: flex; flex-direction: column; gap: 6px; }
.ts-item { font-size: 14px; color: #888888; display: none; }
.ts-item.type-s.show, .ts-item.type-rw.show { display: block; }
.ts-item .rw-star { color: #FF5659; margin-right: 2px; }

.save-wrapper { position: relative; display: inline-flex; align-items: center; }
.save-palette {
  position: absolute; top: 24px; left: 50%; transform: translate(-50%, -5px); display: flex; gap: 8px; opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.save-palette.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.save-chip { background: transparent; border: none; font-family: inherit; font-size: 14px; color: #888888; cursor: pointer; transition: color 0.2s ease; }
.save-chip:hover { color: #5F89FF; }
.menu-row.expand-save { margin-bottom: 28px !important; }

.table-active-group { display: flex; flex-direction: column; align-items: flex-end; }
.table-palette {
  position: absolute; top: 24px; right: 0; display: flex; gap: 12px; opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.2s ease; align-items: center; 
}
.table-palette.show { opacity: 1; visibility: visible; transform: translateY(0); }
.table-chip { background: transparent; border: none; font-family: inherit; font-size: 13px; color: #888888; cursor: pointer; transition: color 0.2s ease, transform 0.1s ease; }
.table-chip:hover { color: #5F89FF; transform: scale(1.1); }
.menu-row.expand-table { margin-bottom: 28px !important; }

.v-table-wrapper { display: inline-block; position: relative; margin: 0 2px; vertical-align: bottom; }
.v-table-cell {
  width: 100%; height: 100%; border: 1px dashed transparent; background: transparent; padding: 2px 6px; box-sizing: border-box; font-size: 14px; line-height: 1.3; color: #333333; outline: none; overflow: hidden; 
}
.v-table-wrapper:hover .v-table-cell, .v-table-cell:focus { border: 1px dashed #D9D9D9; }
.v-resize-handle {
  position: absolute; right: 0px; bottom: 0px; width: 8px; height: 8px; cursor: se-resize; background: #D9D9D9; opacity: 0; transition: opacity 0.2s; z-index: 50;
}
.v-table-wrapper:hover .v-resize-handle { opacity: 1; }
.v-resize-handle:hover { background: #5F89FF; }
.v-delete-handle {
  position: absolute; top: -6px; right: -6px; width: 12px; height: 12px; background: #FF5659; color: #FFFFFF; font-family: inherit; font-size: 10px; line-height: 12px; text-align: center; cursor: pointer; opacity: 0; transition: all 0.2s ease; z-index: 60;
}
.v-table-wrapper:hover .v-delete-handle { opacity: 1; }
.v-delete-handle:hover { transform: scale(1.2); }
.v-extend-btn {
  position: absolute; background: transparent; color: #5F89FF; border: none; font-family: inherit; font-size: 20px; font-weight: normal; cursor: pointer; opacity: 0; visibility: hidden; transition: all 0.2s ease; z-index: 50; padding: 0; line-height: 1;
}
.v-table-wrapper:hover .v-extend-btn { opacity: 1; visibility: visible; }
.v-extend-btn.btn-top { top: -16px; left: 50%; transform: translateX(-50%); }
.v-extend-btn.btn-bottom { bottom: -16px; left: 50%; transform: translateX(-50%); }
.v-extend-btn.btn-left { left: -16px; top: 50%; transform: translateY(-50%); }
.v-extend-btn.btn-right { right: -16px; top: 50%; transform: translateY(-50%); }
.v-extend-btn:hover { transform: translateX(-50%) scale(1.3); }
.v-extend-btn.btn-left:hover, .v-extend-btn.btn-right:hover { transform: translateY(-50%) scale(1.3); }

.celeb-popup {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(249, 249, 247, 0.85); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 0; visibility: hidden; transition: all 0.3s ease; cursor: pointer; 
}
.celeb-popup.show { opacity: 1; visibility: visible; }
.celeb-box { width: 320px; height: 120px; background-color: #D9D9D9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; box-sizing: border-box; }
.celeb-stars { display: flex; gap: 16px; font-size: 24px; line-height: 1; }
.celeb-text { display: flex; font-size: 24px; color: #333333; letter-spacing: 2px; line-height: 1; }
.celeb-stars span, .celeb-text span { display: inline-block; color: #333333; animation: color-wave 0.8s infinite; }
.celeb-stars span:nth-child(1) { animation-delay: 0.0s; }
.celeb-stars span:nth-child(2) { animation-delay: 0.1s; }
.celeb-stars span:nth-child(3) { animation-delay: 0.2s; }
.celeb-stars span:nth-child(4) { animation-delay: 0.3s; }
.celeb-text span:nth-child(1) { animation-delay: 0.0s; }
.celeb-text span:nth-child(2) { animation-delay: 0.05s; }
.celeb-text span:nth-child(3) { animation-delay: 0.1s; }
.celeb-text span:nth-child(4) { animation-delay: 0.15s; }
.celeb-text span:nth-child(5) { animation-delay: 0.2s; }
.celeb-text span:nth-child(6) { animation-delay: 0.25s; }
.celeb-text span:nth-child(7) { animation-delay: 0.3s; }
.celeb-text span:nth-child(8) { animation-delay: 0.35s; }
.celeb-text span:nth-child(9) { animation-delay: 0.4s; }
.celeb-text span:nth-child(10) { animation-delay: 0.45s; }
.celeb-text span:nth-child(11) { animation-delay: 0.5s; }
.celeb-text span:nth-child(12) { animation-delay: 0.55s; }
.celeb-text span:nth-child(13) { animation-delay: 0.6s; }
.celeb-text span:nth-child(14) { animation-delay: 0.65s; }
.celeb-text span:nth-child(15) { animation-delay: 0.7s; }
@keyframes color-wave { 0%, 50%, 100% { color: #333333; } 20% { color: #5F89FF; } }
.pixel-confetti { position: fixed; width: 8px; height: 8px; z-index: 10000; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { 0% { transform: translateY(-10px) rotate(0deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(100vh) rotate(360deg); opacity: 0; } }

.thread-wrapper {
  position: absolute; top: 80px; right: 20px; display: flex; flex-direction: column; align-items: flex-end; z-index: 20; transition: top 0.4s ease; 
}
.thread-wrapper.thread-moved { top: 320px; }
.thread-palette {
  position: absolute; top: 24px; right: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.3s ease; white-space: nowrap; pointer-events: none;
}

/* ✨ 트위스티드 스레드 강제 복구! */
.thread-wrapper.show-menu .thread-palette { 
  opacity: 1 !important; 
  visibility: visible !important; 
  transform: translateY(0) !important; 
  pointer-events: auto !important; 
}

.thread-msg { font-size: 13px; color: #888888; line-height: 1.5; margin-bottom: 8px; text-align: right; }
.thread-item { background: transparent; border: none; font-family: inherit; font-size: 13px; color: #888888; cursor: pointer; transition: color 0.2s ease; padding: 0; }
.thread-item:hover { color: #5F89FF; }

/* ✨ 필사 모드 커서 색상 블루 */
.thread-active .title-input,
.thread-active .body-input {
  caret-color: #5F89FF !important;
}

/* ==========================================
   📱 모바일 & 태블릿 세로 모드 (900px 이하) - 🎬 오프닝 무빙 애니메이션 적용
   ========================================== */
@media screen and (max-width: 900px) {
  /* 1. 기본 레이아웃 & 불필요한 마진 초기화 */
  .container { display: block; min-width: 100%; padding: 0; }
  .memo-area, .typing-mode .memo-area { margin-top: 0 !important; }

  /* 2. 🎬 오프닝 화면 (타이핑 전) */
  /* ACTOF WRITE 제목을 모바일 화면 중앙쯤(약 35vh)으로 훅 내림 */
  .main-header { 
    margin-top: 20vh; 
    padding: 0 60px; 
    text-align: left; 
    /* PC 버전에 있는 transition과 맞물려 부드럽게 올라가는 효과를 줌 */
  }
  
  /* 제목 바로 밑에 '타이핑을 즐겨보세요'가 찰싹 붙어있도록 상단 패딩을 10px로 축소 */
  .memo-input-container {
    padding: 10px 60px 110px 60px !important;
    width: 100%;
    box-sizing: border-box;
    transition: padding 0.4s ease; /* 🌟 무빙 애니메이션의 핵심 */
  }

  /* 3. ✍️ 타이핑 모드 (입력 시작 후) */
  /* 제목이 사라지면서, 본문이 상단 110px 위치로 스르륵 밀고 올라옴 */
  .typing-mode .memo-input-container {
    padding: 110px 60px 110px 60px !important; 
  }

  /* 4. 상단 D9D9D9 메뉴바 배경 (클릭 방해 안 하게 투명화 처리) */
  .typing-mode::before {
    content: ''; position: fixed; top: 0; left: 0; right: 0; height: 50px;
    background-color: #D9D9D9; z-index: 90; pointer-events: none;
  }

  /* 5. 버튼 양쪽 정렬 (겹침 방지 완벽 해결) */
  .typing-mode .thread-wrapper {
    position: fixed; top: 0; left: 60px; right: auto !important;
    width: auto !important; height: 50px;
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
    transform: none; z-index: 100;
  }
  .typing-mode .edit-btn-container {
    position: fixed; top: 0; right: 60px; left: auto !important;
    width: auto !important; height: 50px; padding: 0;
    display: flex; flex-direction: row; align-items: center; justify-content: flex-end;
    transform: none; z-index: 100;
  }

  /* 6. 서브메뉴창 (EFEEEE) 스타일 */
  .edit-menu, .thread-palette {
    position: fixed !important; top: 50px !important; left: 0 !important; right: 0 !important;
    background-color: #EFEEEE !important; padding: 20px 60px !important;
    border-radius: 0 !important; box-sizing: border-box; z-index: 95;
  }
  .thread-palette { align-items: flex-start; }
  .thread-msg { text-align: left; }

  /* 7. 타임스탬프 팝업 */
  .typing-mode .date-stamp {
    position: fixed !important; top: 50% !important; left: 50% !important;
    transform: translate(-50%, -50%) !important; width: 80%; max-width: 320px;
    background-color: #F9F9F7; padding: 30px; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15); z-index: 1000; text-align: center;
    opacity: 0; visibility: hidden; pointer-events: none; transition: all 0.3s ease;
  }
  .typing-mode .date-stamp.show-mobile-popup { opacity: 1; visibility: visible; pointer-events: auto; }
}

/* 8. 모바일 테이블 조절 손잡이 터치 최적화 */
  .v-resize-handle {
    width: 16px !important;
    height: 16px !important;
    right: -4px !important;
    bottom: -4px !important;
    opacity: 0.8 !important; /* 모바일에서는 항상 살짝 보이게 유지 */
  }
  .v-delete-handle {
    width: 20px !important;
    height: 20px !important;
    font-size: 14px !important;
    line-height: 20px !important;
    right: -8px !important;
    top: -8px !important;
    opacity: 0.8 !important;
  }
  .v-extend-btn {
    opacity: 0.7 !important;
    visibility: visible !important;
  }

  /* ==========================================
   🚨 폰트 사이즈 최후 방어선 (PC 14px / 모바일 16px)
   ========================================== */
/* 1. PC 기본 크기 (원래 감성대로 14px 유지) */
.title-input, 
.body-input, 
.v-table-cell {
  font-size: 14px; 
}
.title-input::placeholder {
  font-size: 14px;
}

/* 2. 모바일(900px 이하)에서만 16px로 확대 (iOS 화면 줌인 방지) */
@media screen and (max-width: 900px) {
  .title-input, 
  .body-input, 
  .v-table-cell {
    font-size: 16px !important;
  }
  .title-input::placeholder {
    font-size: 16px !important;
  }
}