/* =========================
   1. 폰트 & 기본 설정
========================= */
@font-face {
  font-family: 'TitleFont';
  src: url('fonts/DNFBitBitv2.ttf') format('truetype');
}

@font-face {
  font-family: 'BodyFont';
  src: url('fonts/Galmuri11.ttf') format('truetype');
}

body {
  margin: 0;
  font-family: 'BodyFont', sans-serif;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

h2, h3, #topText {
  font-family: 'TitleFont', sans-serif;
}

input, textarea {
  font-family: inherit;
}

/* =========================
   2. 전체 레이아웃
========================= */
.container {
  display: flex;
  height: 100vh;
}

.left, .right {
  width: 25%;
  background: #f0f0f0;
  padding: 10px 18px 18px 18px;
  box-sizing: border-box;
  overflow-y: auto;
}

.center {
  width: 50%;
  text-align: center;
  padding: 10px 0 30px;
  box-sizing: border-box;
  overflow-y: auto;
}

/* 좌우 헤더 */
.side-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px;
}

.side-header h3 {
  margin: 0;
}

.side-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0px;
  transform: translateY(-3px);
}

/* =========================
   3. 날짜, 시간, 타이틀
========================= */
#dateTimeBox {
  margin-top: 16px;
  margin-bottom: 14px;
  line-height: 1.4;
  text-align: center;
}

#todayDate {
  font-size: 14px;
  color: #666;
  align-items: center;
}

#currentTime {
  font-size: 24px;
  font-weight: bold;
}

#topText {
  display: block;
  width: 300px;
  margin: 14px auto;
  padding: 32px 28px 32px 28px;
  box-sizing: border-box;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  text-align: center;
  font-size: 1.6em;
  background: #eee;
  border: none;
  outline: none;
  border-radius: 60px;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================
   4. 이미지 & 랜덤 텍스트
========================= */
.image-container {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 10px auto;
  border: 0px solid #ccc;
  overflow: hidden;
  background: #fff;
}

.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  cursor: pointer;
  transition: object-fit 0.2s ease, transform 0.2s ease;
}

.image-container img.contain-mode {
  object-fit: contain;
  background: #fff;
}

.bottom-text {
  width: 300px;
  margin: 10px auto;
  padding: 6px 28px 4px;
  background: transparent;
  box-sizing: border-box;
  min-height: 10px;
  position: relative;
  text-align: center;
}

.bottom-text-content {
  display: block;
  min-height: 0;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.quote-mark {
  position: absolute;
  top: 5px;
  font-size: 20px;
  line-height: 1;
  font-weight: bold;
  color: #555;
  pointer-events: none;
}

.left-quote { left: 8px; }
.right-quote { right: 8px; }

.bottom-text.empty .quote-mark { display: none; }
.bottom-text.empty {
  padding-top: 2px;
  padding-bottom: 2px;
  min-height: 6px;
}

/* =========================
   5. 설정 팝업
========================= */
#settingsPanel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.panel-box {
  background: white;
  border-radius: 10px;
  padding: 24px;
  box-sizing: border-box;
  position: relative;
}

.settings-box {
  width: 760px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.panel-header span {
  font-weight: bold;
  font-size: 20px;
}

.settings-section {
  margin-bottom: 22px;
  text-align: left;
}

.section-title {
  font-weight: bold;
  margin: 10px 10px 10px 4px;
}

/* 썸네일 리스트 */
.thumb-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  border: 1px solid #ccc;
  padding: 10px;
  min-height: 110px;
  box-sizing: border-box;
  background: #fafafa;
  border-radius: 8px;
}

.thumb-item {
  width: 90px;
  height: 90px;
  border: 2px solid transparent;
  flex: 0 0 auto;
  overflow: hidden;
  background: white;
  cursor: pointer;
  margin: 5px;
}

.thumb-item.selected { border: 1px solid #333; }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; }

.settings-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px -4px 0 -4px;
}

/* 문장 리스트 */
.dialogue-list {
  border: 1px solid #ccc;
  padding: 10px;
  min-height: 90px;
  max-height: 140px;
  overflow-y: auto;
  box-sizing: border-box;
  background: #fafafa;
  border-radius: 8px;
}

.dialogue-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  margin-top: 5px;
  margin-bottom: 8px;
  background: white;
}

.dialogue-chip:last-child { margin-bottom: 0; }
.dialogue-text { flex: 1; white-space: pre-wrap; word-break: break-word; }

.dialogue-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

#dialogueInput {
  flex: 1;
  border: 1px solid #555;
  padding: 8px 16px 8px 16px;
  outline: none;
  border-radius: 8px;
}

#dialogueInput:focus {
  flex: 1;
  border: 1px solid #555;
  padding: 8px 16px 8px 16px;
  outline: none;
  border-radius: 8px;
}

/* =========================
   6. 타이머 & 스톱워치 박스
========================= */
.box {
  width: 300px;
  margin: 16px auto;
  padding: 16px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  background: #fff;
  border-radius: 12px;
}

.box-header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 32px;
  margin-bottom: 6px;
}

.box-header h2 {
  margin: 0;
  font-size: 20px;
  text-align: center;
}

.button-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

/* 타이머 입력 */
#t_inputBox {
  font-size: 20px;
  margin: 12px 0;
  margin-bottom: -16px;
  user-select: none;
}

.time-part {
  display: inline-block;
  min-width: 40px;
  text-align: center;
  border-bottom: transparent;
  padding: 2px 4px;
  margin-top: 10px;
}

.time-part:focus {
  outline: none;
  border-bottom: 2px solid #f0f0f0;
}

.colon {
  display: inline-block;
  margin: 0 4px;
}

/* =========================
   7. 기록 & 메모 카드
========================= */
#recordList, #memoList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-card {
  background: white;
  padding: 16px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  border-radius: 8px;
}

.record-card input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
}

.record-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.record-title {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  outline: none;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

.record-icons {
  display: flex;
  gap: 0px;
  align-items: center;
  transform: translateY(-4px);
}

.record-time {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 4px;
}

.record-sub {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.memo {
  position: relative;
  padding: 12px 16px 16px 16px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  background: white;
  border-radius: 8px;
}

.memo textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  overflow: hidden;
  box-sizing: border-box;
  font: inherit;
  line-height: 1.4;
  padding: 24px 0 0 0;
  margin: 0 0 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.memo textarea:focus {
  outline: none;
  box-shadow: none;
}

/* =========================
   8. 공통 버튼 & 아이콘
========================= */
button {
  margin: 5px;
  padding: 7px 12px;
  cursor: pointer;
  border-radius: 16px;
  border: none;
  font-family: inherit;
}

/* 설정 닫기 버튼 */
#closeSettingsPanel {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent url("icons/delete.png") no-repeat center / 24px;
  border: none;
  cursor: pointer;
  width: 30px;
  height: 30px;
}
#closeSettingsPanel:hover { opacity: 0.6; }

/* 이미지 설정 아이콘 */
.image-settings-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 30px;
  height: 30px;
  border: none;
  background-color: transparent;
  background-image: url("icons/settings.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px 24px;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  z-index: 2;
}
.image-settings-btn:hover { opacity: 0.7; }

/* 공통 아이콘 버튼 셋 */
.icon-btn-select, .icon-btn-delete, .icon-btn-add, .icon-btn-record, 
.icon-btn-clear-record, .icon-btn-memo-capture, .icon-btn-memo-clear, .icon-btn-memo-add {
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn-select { width: 30px; height: 30px; background-image: url("icons/file.png"); background-size: 30px 30px; }
.icon-btn-delete { width: 24px; height: 24px; background-image: url("icons/clear.png"); background-size: 24px 24px; }
.icon-btn-add { width: 28px; height: 28px; border: 1px solid #555; background-image: url("icons/add.png"); background-size: 16px 16px; }
.icon-btn-record { padding: 4px; }
.icon-btn-clear-record { width: 25px; height: 25px; background-image: url("icons/clear.png"); background-size: 25px 25px; margin-right: -4px; }
.icon-btn-memo-capture { width: 30px; height: 30px; background-image: url("icons/capture.png"); background-size: 30px 30px; padding: 0; }
.icon-btn-memo-clear { width: 25px; height: 25px; background-image: url("icons/clear.png"); background-size: 25px 25px; padding: 0; margin-right: -4px; }
.icon-btn-memo-add { width: 22px; height: 22px; background-image: url("icons/add.png"); background-size: 22px 22px; padding: 0; }

.icon-btn-select:hover, .icon-btn-delete:hover, .icon-btn-add:hover, .icon-btn-record:hover,
.icon-btn-clear-record:hover, .icon-btn-memo-capture:hover, .icon-btn-memo-clear:hover, .icon-btn-memo-add:hover {
  opacity: 0.7;
}

/* 기록/메모 내부 아이콘 */
.record-side-icon { width: 30px; height: 30px; object-fit: contain; display: block; pointer-events: none; }
.record-type-icon { width: 24px; height: 24px; object-fit: contain; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.record-delete-icon { width: 20px; height: 20px; object-fit: contain; cursor: pointer; padding: 0px; display: flex; align-items: center; justify-content: center; }
.record-delete-icon:hover { opacity: 0.6; }

.dialogue-remove {
  flex: 0 0 auto;
  padding: 2px 8px;
  background: transparent url("icons/delete.png") no-repeat center / 16px;
  border: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
}
.dialogue-remove:hover { opacity: 0.6; }

.memo-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  background-color: transparent;
  background-image: url("icons/delete.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  cursor: pointer;
}
.memo-delete-btn:hover { opacity: 0.6; }

/* 토글 버튼 */
.toggle-icon-btn {
  position: absolute;
  right: 0;
  top: 35%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background-color: transparent;
  background-image: url("icons/toggle.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px 24px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-icon-btn:hover { opacity: 0.7; }
.toggle-icon-btn.is-collapsed { transform: translateY(-50%) rotate(180deg); }

.right-group { display: flex; gap: 0px; align-items: center; }

/* =========================
   9. 좌우 패널 접기
========================= */

.container {
  position: relative;
}

.left, .right {
  position: fixed;
  top: 0;
  height: 100vh;
  width: 25%;
  z-index: 50;
  transition: transform 0.25s ease;
}

.left {
  left: 0;
}

.right {
  right: 0;
}

.center {
  width: 50%;
  margin: 0 auto;
}

/* 접힌 상태 */
.left.is-collapsed {
  transform: translateX(calc(-100% + 14px));
}

.right.is-collapsed {
  transform: translateX(calc(100% - 14px));
}

/* 토글 버튼 */
.side-panel-toggle {
  position: absolute;
  top: 0;
  width: 14px;
  height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.03);
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  cursor: pointer;
  z-index: 999;
}

.left:hover .side-panel-toggle,
.right:hover .side-panel-toggle {
  opacity: 1;
}

.side-panel-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
}

.left-toggle {
  right: 0;
}

.right-toggle {
  left: 0;
}

/* =========================
   10. 스크롤바 숨김
========================= */

/* 기본: 스크롤은 되는데 안 보이게 */
.center {
  scrollbar-width: none;        /* 파이어폭스 */
  -ms-overflow-style: none;     /* 익스플로러 */
}

.center::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

.left, .right {
  scrollbar-width: none;
}

.left::-webkit-scrollbar,
.right::-webkit-scrollbar {
  width: 0;
}

/* =========================
   11. 작은 화면 대응
========================= */

@media (max-width: 900px) {
  .left,
  .right {
    width: 260px;
  }

  .center {
    width: 100%;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
  }

  body.left-panel-open .center {
    width: calc(100% - 260px);
    margin-left: 260px;
    margin-right: 0;
  }

  body.right-panel-open .center {
    width: calc(100% - 260px);
    margin-left: 0;
    margin-right: 260px;
  }

  body.left-panel-open.right-panel-open .center {
    width: calc(100% - 520px);
    margin-left: 260px;
    margin-right: 260px;
  }
}

.side-panel-toggle {
  font-size: 0;
  color: transparent;
  overflow: hidden;
  text-indent: -9999px;
}

/* =========================
   12. 중앙 하단 메뉴
========================= */

.app-menu-btn {
  width: 40px;
  height: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 16px auto 0;

  background: transparent;
  border: none;
  color: #777;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 1px;
}

#appMenuPanel {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.app-menu-box {
  width: 220px;
  padding: 24px;
  background: transparent;
  border-radius: 12px;
  box-sizing: border-box;
  text-align: center;
}

#resetAppBtn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  color: #333;
  padding: 10px 14px;
  border: 1px solid #333;
  background: #fff;
}

#resetAppBtn:hover {
  background: #ddd;
}

/*보조 타이머 추가*/
.app-menu-action-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 12px 0 0 0;
  padding: 10px 14px;
  border: 1px solid #333;
  background: #fff;
  color: #333;
  border-radius: 16px;
  cursor: pointer;
}

.app-menu-action-btn:hover {
  background: #ddd;
}

/* =========================
   13. 메모 색상 선택
========================= */

.memo-color-menu {
  width: 100%;
  box-sizing: border-box;
  margin: 16px 0 0 0;
  padding: 14px;
  border: 1px solid #333;
  border-radius: 12px;
  background: #fff;
}

.memo-color-title {
  font-size: 13px;
  color: #333;
  margin-bottom: 12px;
  text-align: center;
}

/* 컬러칩 영역 */
.memo-color-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* 컬러칩 */
.memo-color-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #333;
  cursor: pointer;
  padding: 0;
}

/* 색상 */
.memo-color-btn[data-index="0"] {
  background: #ffffff;
}

.memo-color-btn[data-index="1"] {
  background: #ffebeb;
}

.memo-color-btn[data-index="2"] {
  background: #e4f7d9;
}

/* hover */
.memo-color-btn:hover {
  transform: scale(1.1);
}

.memo-hex-editor {
  margin-top: 12px;
}

#memoHexInput {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  outline: none;
  text-align: center;
  background: #fff;
}

/* =========================
   14. 서브타이머
========================= */
#subStopwatchBox h2 {
  font-size: 16px;
}

#subTimerBox h2 {
  font-size: 16px;
}

/* =========================
   15. 브라우저 크기조절 대응
========================= */

/* 1. 컨테이너: 필요할 때만 가로 스크롤 허용 */
.container {
  display: flex !important;
  justify-content: flex-start !important;
  overflow-x: auto !important;
  min-width: 0 !important; 
  width: 100% !important;
}

/* 2. 패널: 고정(absolute) 해제, 자연스럽게 열리면서 중앙을 밀어내게 함 */
.left, .right {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  flex-shrink: 0 !important;
  width: 260px !important;
  height: 100vh !important;
  transition: width 0.25s ease, padding 0.25s ease !important;
  overflow-x: hidden !important;
}

/* 3. 중앙 영역: 창을 줄여도 찌그러지지 않게 안전 너비(400px)로 */
.center {
  flex-shrink: 0 !important;
  width: 400px !important;
  margin: 0 auto !important;
}

/* 4. 접힐 때 토글 버튼 크기(14px)만 남기고 줄어듦 */
.left.is-collapsed, .right.is-collapsed {
  width: 14px !important; 
  padding-left: 0 !important;
  padding-right: 0 !important;
  transform: none !important;
}

/* 5. 접힐 때 폰트/아이콘 찌꺼기 깔끔하게 숨김 */
.left.is-collapsed > *:not(.side-panel-toggle),
.right.is-collapsed > *:not(.side-panel-toggle) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.1s ease !important;
}
