/* styles.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: white;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
}

.container {
  background: white;
  display: block;
}

.header {
  margin-bottom: 2px;
}

.nav-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2vh;
  width: 100%;
}

.month-year {
  font-size: 3.5vh;
  color: #2c3e50;
  font-weight: 300;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  min-width: 10vh;
  padding: 1vh 1.5vh;
}

.month-year:hover {
  color: #3498db;
  transform: scale(1.05);
}

.nav-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 1.5vh 2vh;
  border-radius: 0.8vh;
  cursor: pointer;
  font-size: 1.5vh;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 0.15vh 0.7vh rgba(52, 152, 219, 0.3);
  min-width: 10vh;
  white-space: nowrap;
}

.nav-btn:hover {
  background: #2980b9;
  transform: translateY(-0.2vh);
  box-shadow: 0 0.5vh 1.5vh rgba(52, 152, 219, 0.4);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto repeat(6, 1fr);
  gap: 0.2vh;
  background: #ecf0f1;
  border-radius: 1.5vh;
  overflow: hidden;
  flex: 1;
  width: 100vh;
  margin: 0 auto;
  /* 텍스트 선택 방지 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.day-header {
  background: #34495e;
  color: white;
  padding: 2vh;
  text-align: center;
  font-weight: 600;
  font-size: min(2vh, 1.1em);
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-header.sunday {
  background: #e74c3c;
}

.day-header.saturday {
  background: #3498db;
}

.day {
  background: white;
  padding: min(2vh, 20px);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 1;
  /* 텍스트 선택 방지 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* 날짜 셀의 모든 하위 요소들도 텍스트 선택 방지 */
.day * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  pointer-events: none;
}

.day {
  pointer-events: auto;
}

.day:hover {
  background: #f8f9fa;
  transform: translateY(-0.3vh);
  box-shadow: 0 0.8vh 2vh rgba(0, 0, 0, 0.15);
  z-index: 5;
}

.day.today {
  background: white;
  color: inherit;
  border: 2px solid #3498db;
}

.day.today.other-month {
  background: white;
  color: #3498db;
  border: 2px solid #3498db;
}

.day.other-month {
  background: #f8f9fa;
  color: #bdc3c7;
  cursor: not-allowed;
}

.day.other-month:hover {
  transform: none;
  box-shadow: none;
}

.day-number {
  font-size: min(3vh, 1.5em);
  font-weight: 600;
  margin: 0;
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 10;
}

.anniversary {
  position: absolute;
  bottom: 0;
  left: 0;
  font-size: min(1.5vh, 0.7em);
  color: #3498db;
  font-weight: 500;
  background: rgb(255, 255, 255, 0.2);
  padding: 0px 0px;
  border-radius: 0.5vh;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 15;
}

.monthly {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: min(1.5vh, 0.7em);
  color: #2ecc71;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  padding: 0px 0px;
  border-radius: 0.5vh;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 15;
}

.day.sunday .day-number {
  color: #e74c3c;
}

.day.saturday .day-number {
  color: #3498db;
}

.day.today .day-number {
  color: inherit;
}

.day.today.other-month .day-number {
  color: #3498db;
}

.memo-preview {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.9;
}

.day.other-month .memo-preview {
  opacity: 0.3;
}

.memo-preview canvas {
  width: 100%;
  height: 100%;
}

.memo-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  backdrop-filter: blur(0.5vh);
}

.memo-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 2vh;
  padding: min(3vh, 30px);
  width: min(90vw, 900px);
  height: 95vh;
  max-width: 95vw;
  box-shadow: 0 2vh 4vh rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.memo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2vh;
  padding-bottom: 1.5vh;
  border-bottom: 0.2vh solid #f0f0f0;
  flex-shrink: 0;
}

.memo-date {
  font-size: min(3vh, 1.5em);
  font-weight: bold;
  color: #2c3e50;
}

.close-btn {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 50%;
  width: min(4vh, 40px);
  height: min(4vh, 40px);
  cursor: pointer;
  font-size: min(2.6vh, 1.3em);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: #c0392b;
  transform: rotate(90deg);
}

.tools-and-colors {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: min(1vh, 10px);
  margin: 0 auto 1vh auto;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
  width: fit-content;
}

.tools {
  display: flex;
  justify-content: center;
  gap: min(2vh, 20px);
  margin-bottom: 2vh;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.tool-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: min(0.8vh, 8px) min(1.5vh, 15px);
  border-radius: 1.2vh;
  cursor: pointer;
  font-size: min(1.8vh, 0.9em);
  transition: all 0.3s ease;
  font-weight: 500;
  white-space: nowrap;
}

.tool-btn:hover,
.tool-btn.active {
  background: #e74c3c;
  transform: translateY(-0.2vh);
}

.thickness-control {
  display: flex;
  align-items: center;
  gap: min(1.5vh, 15px);
  background: #f8f9fa;
  padding: min(1vh, 10px) min(2vh, 20px);
  border-radius: 1.2vh;
  border: 0.1vh solid #e0e0e0;
}

.thickness-control label {
  font-size: min(2vh, 1em);
  font-weight: bold;
  color: #2c3e50;
}

.thickness-slider {
  width: min(10vh, 100px);
  height: 0.6vh;
  background: #ddd;
  border-radius: 0.6vh;
  outline: none;
  cursor: pointer;
  appearance: none;
}

.thickness-slider::-webkit-slider-thumb {
  appearance: none;
  width: min(1.8vh, 18px);
  height: min(1.8vh, 18px);
  background: #3498db;
  border-radius: 50%;
  cursor: pointer;
}

.thickness-slider::-moz-range-thumb {
  width: min(1.8vh, 18px);
  height: min(1.8vh, 18px);
  background: #3498db;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.thickness-display {
  min-width: min(3vh, 30px);
  text-align: center;
  font-weight: bold;
  color: #2c3e50;
  font-size: min(2.2vh, 1.1em);
}

.color-picker {
  display: flex;
  gap: min(1.5vh, 15px);
  justify-content: center;
  margin-bottom: min(2vh, 20px);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.color-btn {
  width: min(2.5vh, 25px);
  height: min(2.5vh, 25px);
  border-radius: 50%;
  border: 0.2vh solid white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0.2vh 0.5vh rgba(0, 0, 0, 0.2);
}

.color-btn:hover,
.color-btn.active {
  transform: scale(1.2);
  border-color: #333;
}

.canvas-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.save-btn {
  background: #27ae60;
  color: white;
  border: none;
  padding: min(1.5vh, 15px) min(4vh, 40px);
  border-radius: 1.2vh;
  cursor: pointer;
  font-size: min(2.2vh, 1.1em);
  width: 100%;
  transition: all 0.3s ease;
  font-weight: bold;
  flex-shrink: 0;
  margin-top: 0.5vh;
}

.save-btn:hover {
  background: #229954;
  transform: translateY(-0.2vh);
  box-shadow: 0 0.5vh 1.5vh rgba(0, 0, 0, 0.2);
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .container {
    width: 100vw;
    height: auto;
    min-height: auto;
    padding: 0.5vh 0;
    flex-direction: column;
  }

  .header {
    height: auto;
    margin-bottom: 2vw;
    flex-direction: column;
    gap: 0;
  }

  .nav-container {
    gap: 2vw;
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }

  .nav-btn {
    padding: 2vw 3vw;
    font-size: 3.5vw;
    border-radius: 1.5vw;
    flex: 0 0 auto;
    margin: 0;
    min-width: auto;
    white-space: nowrap;
  }

  .month-year {
    font-size: 5vw;
    order: 0;
    width: auto;
    text-align: center;
    margin: 0;
    flex: 1;
    min-width: auto;
    padding: 2vw;
  }

  .calendar {
    width: 98vw !important;
    height: calc(98vw / 7 * 6 + 6vw) !important;
    margin: 0 auto 0 auto;
    gap: 0.1vw;
    border-radius: 1.5vw;
    flex: none;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: 6vw repeat(6, minmax(0, 1fr));
    box-sizing: border-box;
  }

  .day-header {
    padding: 0.3vw;
    font-size: 2.5vw;
    box-sizing: border-box;
    height: 6vw;
  }

  .day {
    padding: 0.2vw;
    min-height: auto;
    aspect-ratio: 1;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
  }

  .day-number {
    font-size: 3.5vw;
    margin: 0;
    position: absolute;
    top: 1vw;
    left: 1vw;
  }

  .anniversary {
    font-size: 1.5vw;
    padding: 0.2vw 0.2vw;
    border-radius: 0.2vw;
    max-width: 70%;
  }

  .monthly {
    font-size: 1.5vw;
    padding: 0.2vw 0.2vw;
    border-radius: 0.2vw;
    max-width: 70%;
  }

  /* 모바일 메모 섹션 */
  .mobile-memo-section {
    width: 100%;
    background: white;
    border-radius: 0;
    padding: 3vw;
    box-shadow: none;
    margin-top: 0;
    border-top: 0.3vw solid #ecf0f1;
  }

  .mobile-memo-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 3vw;
    padding-bottom: 2vw;
    border-bottom: 0.3vw solid #f0f0f0;
  }

  .mobile-memo-date {
    font-size: 4.5vw;
    font-weight: bold;
    color: #2c3e50;
    text-align: center;
  }

  .mobile-tools {
    display: flex;
    justify-content: space-between;
    gap: 1vw;
    margin-bottom: 3vw;
    align-items: center;
    flex-wrap: nowrap;
  }

  .mobile-tool-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 2.5vw 3.5vw;
    border-radius: 2vw;
    cursor: pointer;
    font-size: 3.2vw;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
  }

  .mobile-tool-btn:hover,
  .mobile-tool-btn.active {
    background: #e74c3c;
    transform: translateY(-0.2vh);
  }

  .mobile-thickness-control {
    display: flex;
    align-items: center;
    gap: 2vw;
    background: #f8f9fa;
    padding: 2vw 3vw;
    border-radius: 2vw;
    border: 0.2vw solid #e0e0e0;
  }

  .mobile-thickness-control label {
    font-size: 3.2vw;
    font-weight: bold;
    color: #2c3e50;
    white-space: nowrap;
  }

  .mobile-thickness-slider {
    width: 15vw;
    height: 1vw;
    background: #ddd;
    border-radius: 1vw;
    outline: none;
    cursor: pointer;
    appearance: none;
  }

  .mobile-thickness-slider::-webkit-slider-thumb {
    appearance: none;
    width: 4vw;
    height: 4vw;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
  }

  .mobile-thickness-slider::-moz-range-thumb {
    width: 4vw;
    height: 4vw;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: none;
  }

  .mobile-thickness-display {
    font-size: 3.2vw;
    min-width: 5vw;
    text-align: center;
    font-weight: bold;
    color: #2c3e50;
  }

  .mobile-color-picker {
    display: flex;
    gap: 3vw;
    justify-content: center;
    margin-bottom: 3vw;
    flex-wrap: wrap;
  }

  .mobile-color-btn {
    width: 8vw;
    height: 8vw;
    border-radius: 50%;
    border: 0.5vw solid white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0.5vw 1vw rgba(0, 0, 0, 0.2);
  }

  .mobile-color-btn:hover,
  .mobile-color-btn.active {
    transform: scale(1.2);
    border-color: #333;
  }

  .mobile-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 3vw;
    width: 100%;
  }

  .mobile-canvas {
    border: 0.5vw dashed #ccc;
    border-radius: 2vw;
    background: #fafafa;
    cursor: crosshair;
    display: block;
    width: 90vw;
    height: 90vw;
    aspect-ratio: 1;
    max-width: 500px;
    max-height: 500px;
  }

  .mobile-save-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 3vw 5vw;
    border-radius: 2vw;
    cursor: pointer;
    font-size: 4vw;
    width: 100%;
    transition: all 0.3s ease;
    font-weight: bold;
  }

  .mobile-save-btn:hover {
    background: #229954;
    transform: translateY(-0.2vh);
    box-shadow: 0 0.5vh 1.5vh rgba(0, 0, 0, 0.2);
  }

  .memo-modal {
    display: none !important;
  }
}

/* 데스크톱에서는 모바일 메모 섹션 숨기기 */
@media (min-width: 769px) {
  .mobile-memo-section {
    display: none;
  }
}
